summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-12-29 02:24:24 +0100
committerZach Hilman <zachhilman@gmail.com>2019-01-08 01:19:40 +0100
commit05dbb47af51fb00826912155da85469cb74022db (patch)
tree3162febaeb374ee6310491f75d94b2ec4918b5ae /src/core
parenttime: Use custom RTC settings if applicable for game (diff)
downloadyuzu-05dbb47af51fb00826912155da85469cb74022db.tar
yuzu-05dbb47af51fb00826912155da85469cb74022db.tar.gz
yuzu-05dbb47af51fb00826912155da85469cb74022db.tar.bz2
yuzu-05dbb47af51fb00826912155da85469cb74022db.tar.lz
yuzu-05dbb47af51fb00826912155da85469cb74022db.tar.xz
yuzu-05dbb47af51fb00826912155da85469cb74022db.tar.zst
yuzu-05dbb47af51fb00826912155da85469cb74022db.zip
Diffstat (limited to '')
-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 {
kernel.Initialize();
const auto current_time = std::chrono::duration_cast<std::chrono::seconds>(
- std::chrono::system_clock::now().time_since_epoch())
- .count();
+ std::chrono::system_clock::now().time_since_epoch());
Settings::values.custom_rtc_differential =
Settings::values.custom_rtc.value_or(current_time) - current_time;
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::seconds>(
- 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<u8>();
- 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) {
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 @@
#include <array>
#include <atomic>
+#include <chrono>
#include <map>
#include <optional>
#include <string>
@@ -350,9 +351,10 @@ struct Values {
bool use_docked_mode;
bool enable_nfc;
std::optional<u32> rng_seed;
- std::optional<s64> custom_rtc; // Measured in seconds since epoch
- s64 custom_rtc_differential; // Set on game boot, reset on stop. Seconds difference between
- // current time and `custom_rtc`
+ std::optional<std::chrono::seconds> custom_rtc; // Measured in seconds since epoch
+ std::chrono::seconds
+ custom_rtc_differential; // Set on game boot, reset on stop. Seconds difference between
+ // current time and `custom_rtc`
s32 current_user;
s32 language_index;