summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-12-28 20:24:24 -0500
committerGravatar Zach Hilman2019-01-07 19:19:40 -0500
commit05dbb47af51fb00826912155da85469cb74022db (patch)
tree3162febaeb374ee6310491f75d94b2ec4918b5ae /src/core
parenttime: Use custom RTC settings if applicable for game (diff)
downloadyuzu-05dbb47af51fb00826912155da85469cb74022db.tar.gz
yuzu-05dbb47af51fb00826912155da85469cb74022db.tar.xz
yuzu-05dbb47af51fb00826912155da85469cb74022db.zip
settings: Use std::chrono::seconds instead of s64 for RTC
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.cpp3
-rw-r--r--src/core/hle/service/time/time.cpp10
-rw-r--r--src/core/settings.h8
3 files changed, 10 insertions, 11 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 7459c0851..123b11409 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -96,8 +96,7 @@ struct System::Impl {
96 kernel.Initialize(); 96 kernel.Initialize();
97 97
98 const auto current_time = std::chrono::duration_cast<std::chrono::seconds>( 98 const auto current_time = std::chrono::duration_cast<std::chrono::seconds>(
99 std::chrono::system_clock::now().time_since_epoch()) 99 std::chrono::system_clock::now().time_since_epoch());
100 .count();
101 Settings::values.custom_rtc_differential = 100 Settings::values.custom_rtc_differential =
102 Settings::values.custom_rtc.value_or(current_time) - current_time; 101 Settings::values.custom_rtc.value_or(current_time) - current_time;
103 102
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 @@
16 16
17namespace Service::Time { 17namespace Service::Time {
18 18
19static s64 GetSecondsSinceEpoch() { 19static std::chrono::seconds GetSecondsSinceEpoch() {
20 return std::chrono::duration_cast<std::chrono::seconds>( 20 return std::chrono::duration_cast<std::chrono::seconds>(
21 std::chrono::system_clock::now().time_since_epoch()) 21 std::chrono::system_clock::now().time_since_epoch()) +
22 .count() +
23 Settings::values.custom_rtc_differential; 22 Settings::values.custom_rtc_differential;
24} 23}
25 24
@@ -76,7 +75,7 @@ public:
76 75
77private: 76private:
78 void GetCurrentTime(Kernel::HLERequestContext& ctx) { 77 void GetCurrentTime(Kernel::HLERequestContext& ctx) {
79 const s64 time_since_epoch{GetSecondsSinceEpoch()}; 78 const s64 time_since_epoch{GetSecondsSinceEpoch().count()};
80 LOG_DEBUG(Service_Time, "called"); 79 LOG_DEBUG(Service_Time, "called");
81 80
82 IPC::ResponseBuilder rb{ctx, 4}; 81 IPC::ResponseBuilder rb{ctx, 4};
@@ -272,8 +271,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) {
272 IPC::RequestParser rp{ctx}; 271 IPC::RequestParser rp{ctx};
273 const auto initial_type = rp.PopRaw<u8>(); 272 const auto initial_type = rp.PopRaw<u8>();
274 273
275 const s64 time_since_epoch{GetSecondsSinceEpoch()}; 274 const s64 time_since_epoch{GetSecondsSinceEpoch().count()};
276
277 const std::time_t time(time_since_epoch); 275 const std::time_t time(time_since_epoch);
278 const std::tm* tm = std::localtime(&time); 276 const std::tm* tm = std::localtime(&time);
279 if (tm == nullptr) { 277 if (tm == nullptr) {
diff --git a/src/core/settings.h b/src/core/settings.h
index 5b211a716..bb5aafa0c 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -6,6 +6,7 @@
6 6
7#include <array> 7#include <array>
8#include <atomic> 8#include <atomic>
9#include <chrono>
9#include <map> 10#include <map>
10#include <optional> 11#include <optional>
11#include <string> 12#include <string>
@@ -350,9 +351,10 @@ struct Values {
350 bool use_docked_mode; 351 bool use_docked_mode;
351 bool enable_nfc; 352 bool enable_nfc;
352 std::optional<u32> rng_seed; 353 std::optional<u32> rng_seed;
353 std::optional<s64> custom_rtc; // Measured in seconds since epoch 354 std::optional<std::chrono::seconds> custom_rtc; // Measured in seconds since epoch
354 s64 custom_rtc_differential; // Set on game boot, reset on stop. Seconds difference between 355 std::chrono::seconds
355 // current time and `custom_rtc` 356 custom_rtc_differential; // Set on game boot, reset on stop. Seconds difference between
357 // current time and `custom_rtc`
356 s32 current_user; 358 s32 current_user;
357 s32 language_index; 359 s32 language_index;
358 360