summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-12-28 19:09:57 -0500
committerGravatar Zach Hilman2019-01-07 19:19:40 -0500
commitdbb1eb9c29e072e77b66efa28ea21e814100d6ee (patch)
treec180635840adf9d1555262bf68d223bcd78fb691 /src
parentcore: Set custom RTC differential on game boot (diff)
downloadyuzu-dbb1eb9c29e072e77b66efa28ea21e814100d6ee.tar.gz
yuzu-dbb1eb9c29e072e77b66efa28ea21e814100d6ee.tar.xz
yuzu-dbb1eb9c29e072e77b66efa28ea21e814100d6ee.zip
time: Use custom RTC settings if applicable for game
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/time/time.cpp16
-rw-r--r--src/yuzu_cmd/default_ini.h4
2 files changed, 12 insertions, 8 deletions
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 @@
12#include "core/hle/kernel/client_session.h" 12#include "core/hle/kernel/client_session.h"
13#include "core/hle/service/time/interface.h" 13#include "core/hle/service/time/interface.h"
14#include "core/hle/service/time/time.h" 14#include "core/hle/service/time/time.h"
15#include "core/settings.h"
15 16
16namespace Service::Time { 17namespace Service::Time {
17 18
19static s64 GetSecondsSinceEpoch() {
20 return std::chrono::duration_cast<std::chrono::seconds>(
21 std::chrono::system_clock::now().time_since_epoch())
22 .count() +
23 Settings::values.custom_rtc_differential;
24}
25
18static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time, 26static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time,
19 CalendarAdditionalInfo& additional_info, 27 CalendarAdditionalInfo& additional_info,
20 [[maybe_unused]] const TimeZoneRule& /*rule*/) { 28 [[maybe_unused]] const TimeZoneRule& /*rule*/) {
@@ -68,9 +76,7 @@ public:
68 76
69private: 77private:
70 void GetCurrentTime(Kernel::HLERequestContext& ctx) { 78 void GetCurrentTime(Kernel::HLERequestContext& ctx) {
71 const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( 79 const s64 time_since_epoch{GetSecondsSinceEpoch()};
72 std::chrono::system_clock::now().time_since_epoch())
73 .count()};
74 LOG_DEBUG(Service_Time, "called"); 80 LOG_DEBUG(Service_Time, "called");
75 81
76 IPC::ResponseBuilder rb{ctx, 4}; 82 IPC::ResponseBuilder rb{ctx, 4};
@@ -266,9 +272,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
266 IPC::RequestParser rp{ctx}; 272 IPC::RequestParser rp{ctx};
267 const auto initial_type = rp.PopRaw<u8>(); 273 const auto initial_type = rp.PopRaw<u8>();
268 274
269 const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( 275 const s64 time_since_epoch{GetSecondsSinceEpoch()};
270 std::chrono::system_clock::now().time_since_epoch())
271 .count()};
272 276
273 const std::time_t time(time_since_epoch); 277 const std::time_t time(time_since_epoch);
274 const std::tm* tm = std::localtime(&time); 278 const std::tm* tm = std::localtime(&time);
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h
index 0a3ea2619..ba51a4a51 100644
--- a/src/yuzu_cmd/default_ini.h
+++ b/src/yuzu_cmd/default_ini.h
@@ -186,8 +186,8 @@ rng_seed =
186# Sets the current time (in seconds since 12:00 AM Jan 1, 1970) that will be used by the time service 186# Sets the current time (in seconds since 12:00 AM Jan 1, 1970) that will be used by the time service
187# This will auto-increment, with the time set being the time the game is started 187# This will auto-increment, with the time set being the time the game is started
188# This override will only occur if custom_rtc_enabled is true, otherwise the current time is used 188# This override will only occur if custom_rtc_enabled is true, otherwise the current time is used
189custom_rtc_enabled = 189custom_rtc_enabled =
190custom_rtc = 190custom_rtc =
191 191
192# Sets the account username, max length is 32 characters 192# Sets the account username, max length is 32 characters
193# yuzu (default) 193# yuzu (default)