mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
msvc: use std::chrono for GetLocalTimeSinceJan1970
This commit is contained in:
parent
b473c35873
commit
86da6c98fb
@ -7,7 +7,6 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#include <ctime>
|
||||
#include <timeapi.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
@ -82,6 +81,12 @@ u64 Timer::ElapsedMs() const
|
||||
|
||||
u64 Timer::GetLocalTimeSinceJan1970()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
std::chrono::zoned_seconds seconds(
|
||||
std::chrono::current_zone(),
|
||||
std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()));
|
||||
return seconds.get_local_time().time_since_epoch().count();
|
||||
#else
|
||||
time_t sysTime, tzDiff, tzDST;
|
||||
time(&sysTime);
|
||||
tm* gmTime = localtime(&sysTime);
|
||||
@ -97,6 +102,7 @@ u64 Timer::GetLocalTimeSinceJan1970()
|
||||
tzDiff = sysTime - mktime(gmTime);
|
||||
|
||||
return static_cast<u64>(sysTime + tzDiff + tzDST);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Timer::IncreaseResolution()
|
||||
|
Loading…
Reference in New Issue
Block a user