From bc0e8158b3da9a88f7ce1c3413fcc22bcff1e30d Mon Sep 17 00:00:00 2001 From: Sketch <75850871+SketchMaster2001@users.noreply.github.com> Date: Tue, 20 Jun 2023 22:49:33 -0400 Subject: [PATCH] IOS/KD/Time: Take into account DST for AdjustedUTC --- Source/Core/Core/IOS/Network/KD/NetKDTime.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/IOS/Network/KD/NetKDTime.cpp b/Source/Core/Core/IOS/Network/KD/NetKDTime.cpp index e267dadf17..6764be4053 100644 --- a/Source/Core/Core/IOS/Network/KD/NetKDTime.cpp +++ b/Source/Core/Core/IOS/Network/KD/NetKDTime.cpp @@ -91,19 +91,29 @@ u64 NetKDTimeDevice::GetAdjustedUTC() const { using namespace ExpansionInterface; + time_t dst_diff{}; const time_t current_time = CEXIIPL::GetEmulatedTime(GetSystem(), CEXIIPL::UNIX_EPOCH); tm* const gm_time = gmtime(¤t_time); + const u32 emulated_time = mktime(gm_time); - return u64(s64(emulated_time) + utcdiff); + if (gm_time->tm_isdst == 1) + dst_diff = 3600; + + return u64(s64(emulated_time) + utcdiff - dst_diff); } void NetKDTimeDevice::SetAdjustedUTC(u64 wii_utc) { using namespace ExpansionInterface; + time_t dst_diff{}; const time_t current_time = CEXIIPL::GetEmulatedTime(GetSystem(), CEXIIPL::UNIX_EPOCH); tm* const gm_time = gmtime(¤t_time); + const u32 emulated_time = mktime(gm_time); - utcdiff = s64(emulated_time - wii_utc); + if (gm_time->tm_isdst == 1) + dst_diff = 3600; + + utcdiff = s64(emulated_time - wii_utc - dst_diff); } } // namespace IOS::HLE