Skip to content

Commit

Permalink
Merge pull request #11983 from noahpistilli/fix-kd-utc
Browse files Browse the repository at this point in the history
IOS/KD/Time: Take into account DST for AdjustedUTC
  • Loading branch information
JMC47 committed Jun 21, 2023
2 parents 5ad2d86 + bc0e815 commit 6c50de0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Source/Core/Core/IOS/Network/KD/NetKDTime.cpp
Expand Up @@ -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(&current_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(&current_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

0 comments on commit 6c50de0

Please sign in to comment.