From dbb1eb9c29e072e77b66efa28ea21e814100d6ee Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Fri, 28 Dec 2018 19:09:57 -0500 Subject: time: Use custom RTC settings if applicable for game --- src/core/hle/service/time/time.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 16564de24..ef8c9f2b7 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -12,9 +12,17 @@ #include "core/hle/kernel/client_session.h" #include "core/hle/service/time/interface.h" #include "core/hle/service/time/time.h" +#include "core/settings.h" namespace Service::Time { +static s64 GetSecondsSinceEpoch() { + return std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count() + + Settings::values.custom_rtc_differential; +} + static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time, CalendarAdditionalInfo& additional_info, [[maybe_unused]] const TimeZoneRule& /*rule*/) { @@ -68,9 +76,7 @@ public: private: void GetCurrentTime(Kernel::HLERequestContext& ctx) { - const s64 time_since_epoch{std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count()}; + const s64 time_since_epoch{GetSecondsSinceEpoch()}; LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 4}; @@ -266,9 +272,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto initial_type = rp.PopRaw(); - const s64 time_since_epoch{std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count()}; + const s64 time_since_epoch{GetSecondsSinceEpoch()}; const std::time_t time(time_since_epoch); const std::tm* tm = std::localtime(&time); -- cgit v1.2.3 From 05dbb47af51fb00826912155da85469cb74022db Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Fri, 28 Dec 2018 20:24:24 -0500 Subject: settings: Use std::chrono::seconds instead of s64 for RTC --- src/core/hle/service/time/time.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index ef8c9f2b7..c13640ad8 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -16,10 +16,9 @@ namespace Service::Time { -static s64 GetSecondsSinceEpoch() { +static std::chrono::seconds GetSecondsSinceEpoch() { return std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count() + + std::chrono::system_clock::now().time_since_epoch()) + Settings::values.custom_rtc_differential; } @@ -76,7 +75,7 @@ public: private: void GetCurrentTime(Kernel::HLERequestContext& ctx) { - const s64 time_since_epoch{GetSecondsSinceEpoch()}; + const s64 time_since_epoch{GetSecondsSinceEpoch().count()}; LOG_DEBUG(Service_Time, "called"); IPC::ResponseBuilder rb{ctx, 4}; @@ -272,8 +271,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto initial_type = rp.PopRaw(); - const s64 time_since_epoch{GetSecondsSinceEpoch()}; - + const s64 time_since_epoch{GetSecondsSinceEpoch().count()}; const std::time_t time(time_since_epoch); const std::tm* tm = std::localtime(&time); if (tm == nullptr) { -- cgit v1.2.3