summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Timer.cpp
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2025-03-16 00:32:54 -0500
committeriwubcode <iwubcode@users.noreply.github.com>2025-03-16 00:59:45 -0500
commitc1dea828ab311ac68b85136a97695f447b3b2574 (patch)
tree553e3dc9fa3b035ab943034c4b45d3488da68434 /Source/Core/Common/Timer.cpp
parent452cd1c2614c3b1dde2c6f2f594c9dc3f6471163 (diff)
Common: use std::chrono for GetLocalTimeSinceJan1970 on Windows
Co-authored-by: Shawn Hoffman <godisgovernment@gmail.com>
Diffstat (limited to 'Source/Core/Common/Timer.cpp')
-rw-r--r--Source/Core/Common/Timer.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp
index 91381eebd3..fb81164390 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>
@@ -68,10 +67,12 @@ 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
+#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);
@@ -87,6 +88,7 @@ u64 Timer::GetLocalTimeSinceJan1970()
tzDiff = sysTime - mktime(gmTime);
return static_cast<u64>(sysTime + tzDiff + tzDST);
+#endif
}
void Timer::IncreaseResolution()