summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar bunnei2019-01-10 17:05:21 -0500
committerGravatar GitHub2019-01-10 17:05:21 -0500
commitc9ef8b0af1a5908822ca0f3bb3b2238018a555e8 (patch)
tree157da486e44b5f7083607159e1bb8bb3e4f20842 /src/core/hle
parentMerge pull request #1939 from DarkLordZach/web-applet (diff)
parentsettings: Fix comment structure (diff)
downloadyuzu-c9ef8b0af1a5908822ca0f3bb3b2238018a555e8.tar.gz
yuzu-c9ef8b0af1a5908822ca0f3bb3b2238018a555e8.tar.xz
yuzu-c9ef8b0af1a5908822ca0f3bb3b2238018a555e8.zip
Merge pull request #1959 from DarkLordZach/custom-rtc
settings: Add support for setting the RTC manually
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/time/time.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 16564de24..c13640ad8 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -12,9 +12,16 @@
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 std::chrono::seconds GetSecondsSinceEpoch() {
20 return std::chrono::duration_cast<std::chrono::seconds>(
21 std::chrono::system_clock::now().time_since_epoch()) +
22 Settings::values.custom_rtc_differential;
23}
24
18static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time, 25static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time,
19 CalendarAdditionalInfo& additional_info, 26 CalendarAdditionalInfo& additional_info,
20 [[maybe_unused]] const TimeZoneRule& /*rule*/) { 27 [[maybe_unused]] const TimeZoneRule& /*rule*/) {
@@ -68,9 +75,7 @@ public:
68 75
69private: 76private:
70 void GetCurrentTime(Kernel::HLERequestContext& ctx) { 77 void GetCurrentTime(Kernel::HLERequestContext& ctx) {
71 const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( 78 const s64 time_since_epoch{GetSecondsSinceEpoch().count()};
72 std::chrono::system_clock::now().time_since_epoch())
73 .count()};
74 LOG_DEBUG(Service_Time, "called"); 79 LOG_DEBUG(Service_Time, "called");
75 80
76 IPC::ResponseBuilder rb{ctx, 4}; 81 IPC::ResponseBuilder rb{ctx, 4};
@@ -266,10 +271,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
266 IPC::RequestParser rp{ctx}; 271 IPC::RequestParser rp{ctx};
267 const auto initial_type = rp.PopRaw<u8>(); 272 const auto initial_type = rp.PopRaw<u8>();
268 273
269 const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( 274 const s64 time_since_epoch{GetSecondsSinceEpoch().count()};
270 std::chrono::system_clock::now().time_since_epoch())
271 .count()};
272
273 const std::time_t time(time_since_epoch); 275 const std::time_t time(time_since_epoch);
274 const std::tm* tm = std::localtime(&time); 276 const std::tm* tm = std::localtime(&time);
275 if (tm == nullptr) { 277 if (tm == nullptr) {