From ef811c64259f0b83aa72c99bad9d4e48082129f8 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sat, 16 Oct 2021 02:07:18 -0400 Subject: settings: Remove std::chrono usage Alleviates the dependency on chrono for all files that include settings.h --- src/core/core.cpp | 5 +++-- src/core/hle/service/time/time_manager.cpp | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/core.cpp b/src/core/core.cpp index 3042d611b..3c75f42ae 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -196,8 +196,9 @@ struct System::Impl { cpu_manager.Initialize(); core_timing.Initialize([&system]() { system.RegisterHostThread(); }); - const auto current_time = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()); + const auto posix_time = std::chrono::system_clock::now().time_since_epoch(); + const auto current_time = + std::chrono::duration_cast(posix_time).count(); Settings::values.custom_rtc_differential = Settings::values.custom_rtc.value_or(current_time) - current_time; diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index 4bbc606a1..9c4c960ef 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp @@ -13,18 +13,19 @@ #include "core/hle/service/time/time_manager.h" namespace Service::Time { - +namespace { constexpr Clock::TimeSpanType standard_network_clock_accuracy{0x0009356907420000ULL}; -static std::chrono::seconds GetSecondsSinceEpoch() { - return std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) + +s64 GetSecondsSinceEpoch() { + const auto time_since_epoch = std::chrono::system_clock::now().time_since_epoch(); + return std::chrono::duration_cast(time_since_epoch).count() + Settings::values.custom_rtc_differential; } -static s64 GetExternalRtcValue() { - return GetSecondsSinceEpoch().count() + TimeManager::GetExternalTimeZoneOffset(); +s64 GetExternalRtcValue() { + return GetSecondsSinceEpoch() + TimeManager::GetExternalTimeZoneOffset(); } +} // Anonymous namespace struct TimeManager::Impl final { explicit Impl(Core::System& system) -- cgit v1.2.3