From bcc3c3172da63faa8173a25f9e65eb14dff8a260 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Thu, 26 Dec 2024 11:31:37 +0100 Subject: [PATCH] [Base] Added NtSystemClock to_local for quick time conversion to current timezone - Changed achievement reward time to local time (in UI) --- src/xenia/base/chrono.h | 8 ++++++++ src/xenia/kernel/xam/xam_ui.cc | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/xenia/base/chrono.h b/src/xenia/base/chrono.h index b1c252ac3..74e890575 100644 --- a/src/xenia/base/chrono.h +++ b/src/xenia/base/chrono.h @@ -91,6 +91,14 @@ struct NtSystemClock { return sys_time{cdp.time_since_epoch()}; } + template + static constexpr std::enable_if_t< + domain_fresh_ == Domain::Host, + std::chrono::local_time> + to_local(const time_point& tp) { + return std::chrono::current_zone()->to_local(to_sys(tp)); + } + template static constexpr std::enable_if_t from_sys(const std::chrono::system_clock::time_point& tp) { diff --git a/src/xenia/kernel/xam/xam_ui.cc b/src/xenia/kernel/xam/xam_ui.cc index 6b38b5039..7d2803e88 100644 --- a/src/xenia/kernel/xam/xam_ui.cc +++ b/src/xenia/kernel/xam/xam_ui.cc @@ -394,7 +394,7 @@ struct AchievementInfo { uint32_t gamerscore; uint32_t image_id; uint32_t flags; - std::chrono::system_clock::time_point unlock_time; + std::chrono::local_time unlock_time; bool IsUnlocked() const { return (flags & static_cast(AchievementFlags::kAchieved)) || @@ -462,7 +462,7 @@ class GameAchievementsDialog final : public XamDialog { if (entry.IsUnlocked()) { info.unlock_time = - chrono::WinSystemClock::to_sys(entry.unlock_time.to_time_point()); + chrono::WinSystemClock::to_local(entry.unlock_time.to_time_point()); } achievements_info_.insert({info.id, info});