[Base] Added NtSystemClock to_local for quick time conversion to current timezone

- Changed achievement reward time to local time (in UI)
This commit is contained in:
Gliniak 2024-12-26 11:31:37 +01:00 committed by Radosław Gliński
parent c3586bc165
commit bcc3c3172d
2 changed files with 10 additions and 2 deletions

View File

@ -91,6 +91,14 @@ struct NtSystemClock {
return sys_time{cdp.time_since_epoch()};
}
template <Domain domain_fresh_ = domain_>
static constexpr std::enable_if_t<
domain_fresh_ == Domain::Host,
std::chrono::local_time<std::chrono::system_clock::duration>>
to_local(const time_point& tp) {
return std::chrono::current_zone()->to_local(to_sys(tp));
}
template <Domain domain_fresh_ = domain_>
static constexpr std::enable_if_t<domain_fresh_ == Domain::Host, time_point>
from_sys(const std::chrono::system_clock::time_point& tp) {

View File

@ -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<std::chrono::system_clock::duration> unlock_time;
bool IsUnlocked() const {
return (flags & static_cast<uint32_t>(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});