parent
e49d8f8b4c
commit
658877c350
1 changed files with 13 additions and 3 deletions
|
@ -2400,12 +2400,19 @@ OS::Date OS_Windows::get_date(bool utc) const {
|
||||||
else
|
else
|
||||||
GetLocalTime(&systemtime);
|
GetLocalTime(&systemtime);
|
||||||
|
|
||||||
|
// Get DST information from Windows, but only if utc is false.
|
||||||
|
TIME_ZONE_INFORMATION info;
|
||||||
|
bool daylight = false;
|
||||||
|
if (!utc && GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) {
|
||||||
|
daylight = true;
|
||||||
|
}
|
||||||
|
|
||||||
Date date;
|
Date date;
|
||||||
date.day = systemtime.wDay;
|
date.day = systemtime.wDay;
|
||||||
date.month = Month(systemtime.wMonth);
|
date.month = Month(systemtime.wMonth);
|
||||||
date.weekday = Weekday(systemtime.wDayOfWeek);
|
date.weekday = Weekday(systemtime.wDayOfWeek);
|
||||||
date.year = systemtime.wYear;
|
date.year = systemtime.wYear;
|
||||||
date.dst = false;
|
date.dst = daylight;
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
OS::Time OS_Windows::get_time(bool utc) const {
|
OS::Time OS_Windows::get_time(bool utc) const {
|
||||||
|
@ -2428,16 +2435,19 @@ OS::TimeZoneInfo OS_Windows::get_time_zone_info() const {
|
||||||
if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT)
|
if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT)
|
||||||
daylight = true;
|
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;
|
TimeZoneInfo ret;
|
||||||
if (daylight) {
|
if (daylight) {
|
||||||
ret.name = info.DaylightName;
|
ret.name = info.DaylightName;
|
||||||
|
ret.bias = info.Bias + info.DaylightBias;
|
||||||
} else {
|
} else {
|
||||||
ret.name = info.StandardName;
|
ret.name = info.StandardName;
|
||||||
|
ret.bias = info.Bias + info.StandardBias;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bias value returned by GetTimeZoneInformation is inverted of what we expect
|
// 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
|
// 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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue