diff options
| author | Shawn Hoffman <godisgovernment@gmail.com> | 2022-07-18 01:10:22 -0700 |
|---|---|---|
| committer | Shawn Hoffman <godisgovernment@gmail.com> | 2022-08-02 22:24:06 -0700 |
| commit | 86da6c98fbd229d87de7cf8b9c7eb94c16923829 (patch) | |
| tree | c10e3aa076651d75c34a0932dd32d814986dc52c /Source/Core/Common/Timer.cpp | |
| parent | b473c3587388e06823c153c4fecc2104bcafedff (diff) | |
msvc: use std::chrono for GetLocalTimeSinceJan1970
Diffstat (limited to 'Source/Core/Common/Timer.cpp')
| -rw-r--r-- | Source/Core/Common/Timer.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index 3d2a2ed777..1b80e02880 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -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() |
