Merge pull request #11983 from noahpistilli/fix-kd-utc

IOS/KD/Time: Take into account DST for AdjustedUTC
This commit is contained in:
JMC47 2023-06-21 11:09:02 -04:00 committed by GitHub
commit 6c50de06be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,19 +91,29 @@ u64 NetKDTimeDevice::GetAdjustedUTC() const
{ {
using namespace ExpansionInterface; using namespace ExpansionInterface;
time_t dst_diff{};
const time_t current_time = CEXIIPL::GetEmulatedTime(GetSystem(), CEXIIPL::UNIX_EPOCH); const time_t current_time = CEXIIPL::GetEmulatedTime(GetSystem(), CEXIIPL::UNIX_EPOCH);
tm* const gm_time = gmtime(&current_time); tm* const gm_time = gmtime(&current_time);
const u32 emulated_time = mktime(gm_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) void NetKDTimeDevice::SetAdjustedUTC(u64 wii_utc)
{ {
using namespace ExpansionInterface; using namespace ExpansionInterface;
time_t dst_diff{};
const time_t current_time = CEXIIPL::GetEmulatedTime(GetSystem(), CEXIIPL::UNIX_EPOCH); const time_t current_time = CEXIIPL::GetEmulatedTime(GetSystem(), CEXIIPL::UNIX_EPOCH);
tm* const gm_time = gmtime(&current_time); tm* const gm_time = gmtime(&current_time);
const u32 emulated_time = mktime(gm_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 } // namespace IOS::HLE