From 292724b2280da23a2cebd5682d504a113bc45c83 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sat, 6 Aug 2022 22:22:14 -0700 Subject: [PATCH 1/2] Revert "msvc: use std::chrono for GetLocalTimeSinceJan1970" This reverts commit 86da6c98fbd229d87de7cf8b9c7eb94c16923829. --- Source/Core/Common/Timer.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index fb81164390..5e4af1ef45 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -7,6 +7,7 @@ #ifdef _WIN32 #include +#include #include #else #include @@ -67,12 +68,6 @@ 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::system_clock::now())); - return seconds.get_local_time().time_since_epoch().count(); -#else time_t sysTime, tzDiff, tzDST; time(&sysTime); tm* gmTime = localtime(&sysTime); @@ -88,7 +83,6 @@ u64 Timer::GetLocalTimeSinceJan1970() tzDiff = sysTime - mktime(gmTime); return static_cast(sysTime + tzDiff + tzDST); -#endif } void Timer::IncreaseResolution() From 6e94c20abdbb5284a78afbdca627f1528f78dbc3 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sat, 6 Aug 2022 22:25:30 -0700 Subject: [PATCH 2/2] add TODO for chrono in GetLocalTimeSinceJan1970 --- Source/Core/Common/Timer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index 5e4af1ef45..91381eebd3 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -68,6 +68,10 @@ u64 Timer::ElapsedMs() const u64 Timer::GetLocalTimeSinceJan1970() { + // TODO Would really, really like to use std::chrono here, but Windows did not support + // std::chrono::current_zone() until 19H1, and other compilers don't even provide support for + // timezone-related parts of chrono. Someday! + // see https://bugs.dolphin-emu.org/issues/13007#note-4 time_t sysTime, tzDiff, tzDST; time(&sysTime); tm* gmTime = localtime(&sysTime);