GetTimeZoneInformation
fills up a TIME_ZONE_INFO
struct with all sorts of useful information.
Except it doesn't actually tell me if the current local time zone is in daylight savings or not.
For that matter, I'm in New York and the StandardBias
and DaylightBias
both say the same thing as the Bias
.
What's going on?
The return code of GetTimeZoneInformation
contains the information you want.
According to MSDN:
If the function succeeds, it returns one of the following values.
TIME_ZONE_ID_UNKNOWN
0
Daylight saving time is not used in the current time zone, because there are no transition dates or automatic adjustment for daylight saving time is disabled.TIME_ZONE_ID_STANDARD
1
The system is operating in the range covered by the StandardDate member of theTIME_ZONE_INFORMATION
structure.TIME_ZONE_ID_DAYLIGHT
2
The system is operating in the range covered by the DaylightDate member of theTIME_ZONE_INFORMATION
structure.If the function fails for other reasons, such as an out of memory error, it returns TIME_ZONE_ID_INVALID. To get extended error information, call
GetLastError
.
Make sure you check the return code to ensure the information you are receiving is indeed valid.