如何确定当前本地时间是否为夏令时

How to find out if the current local time is in daylight savings

GetTimeZoneInformation 用各种有用的信息填充 TIME_ZONE_INFO 结构。

除了它实际上没有告诉我当前本地时区是否在夏令时。

就此而言,我在纽约,StandardBiasDaylightBias 都和 Bias 说同样的话。

怎么回事?

GetTimeZoneInformation的return代码包含您想要的信息。

根据 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 the TIME_ZONE_INFORMATION structure.

TIME_ZONE_ID_DAYLIGHT
2
The system is operating in the range covered by the DaylightDate member of the TIME_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.

确保检查 return 代码以确保您收到的信息确实有效。