diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-03-17 12:39:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-17 12:39:10 +0100 |
commit | 5d806b435bdfb6669435f1a28589f847be5ff807 (patch) | |
tree | 0b3e6c67aeacadc9829658f2123ad6aa66b64ebf | |
parent | 5c4de463fecefa10c46aae77bc931cfd47f44ffa (diff) | |
parent | 4802f152317e5750f6d55a1cae621c9908dbdab5 (diff) |
Merge pull request #59223 from ztc0611/master
-rw-r--r-- | platform/windows/os_windows.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 13e3aa7883..b4669e452a 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -264,12 +264,19 @@ OS::Date OS_Windows::get_date(bool p_utc) const { GetLocalTime(&systemtime); } + //Get DST information from Windows, but only if p_utc is false. + TIME_ZONE_INFORMATION info; + bool daylight = false; + if (!p_utc && GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) { + daylight = true; + } + Date date; date.day = systemtime.wDay; date.month = Month(systemtime.wMonth); date.weekday = Weekday(systemtime.wDayOfWeek); date.year = systemtime.wYear; - date.dst = false; + date.dst = daylight; return date; } @@ -295,16 +302,19 @@ OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { daylight = true; } + // Daylight Bias needs to be added to the bias if DST is in effect, or else it will not properly update. TimeZoneInfo ret; if (daylight) { ret.name = info.DaylightName; + ret.bias = info.Bias + info.DaylightBias; } else { ret.name = info.StandardName; + ret.bias = info.Bias + info.StandardBias; } // Bias value returned by GetTimeZoneInformation is inverted of what we expect // For example, on GMT-3 GetTimeZoneInformation return a Bias of 180, so invert the value to get -180 - ret.bias = -info.Bias; + ret.bias = -ret.bias; return ret; } |