mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-12 23:48:58 +01:00
Merge pull request #10963 from shuffle2/notime
back out using std::chrono for timezone stuff
This commit is contained in:
commit
d69f38f415
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <ctime>
|
||||||
#include <timeapi.h>
|
#include <timeapi.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -67,12 +68,10 @@ u64 Timer::ElapsedMs() const
|
|||||||
|
|
||||||
u64 Timer::GetLocalTimeSinceJan1970()
|
u64 Timer::GetLocalTimeSinceJan1970()
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
// TODO Would really, really like to use std::chrono here, but Windows did not support
|
||||||
std::chrono::zoned_seconds seconds(
|
// std::chrono::current_zone() until 19H1, and other compilers don't even provide support for
|
||||||
std::chrono::current_zone(),
|
// timezone-related parts of chrono. Someday!
|
||||||
std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()));
|
// see https://bugs.dolphin-emu.org/issues/13007#note-4
|
||||||
return seconds.get_local_time().time_since_epoch().count();
|
|
||||||
#else
|
|
||||||
time_t sysTime, tzDiff, tzDST;
|
time_t sysTime, tzDiff, tzDST;
|
||||||
time(&sysTime);
|
time(&sysTime);
|
||||||
tm* gmTime = localtime(&sysTime);
|
tm* gmTime = localtime(&sysTime);
|
||||||
@ -88,7 +87,6 @@ u64 Timer::GetLocalTimeSinceJan1970()
|
|||||||
tzDiff = sysTime - mktime(gmTime);
|
tzDiff = sysTime - mktime(gmTime);
|
||||||
|
|
||||||
return static_cast<u64>(sysTime + tzDiff + tzDST);
|
return static_cast<u64>(sysTime + tzDiff + tzDST);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::IncreaseResolution()
|
void Timer::IncreaseResolution()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user