问题
The .Net / Windows TimeZoneInfo object for W. Aus Standard Time shows that it supports daylight savings time. A search on the Australian government site regarding territories' observance of daylight savings shows Western Australia repealed it in 2009, so no daylight savings from 2010 to present and beyond.
I have checked the TimeZoneInfo object on several systems, and they all say W Aus Standard Time supports dst. All their registries have the same value. I have checked Windows Updates and can find no update to the TimeZoneInfo object.
Can anyone shed light on why Microsoft has seemingly overlooked updating this object for 7+ years? Am I missing something?
回答1:
I believe you are seeing this:
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("W. Australia Standard Time");
tzi.SupportsDaylightSavingTime == true
Per the MSDN documentation on the SupportsDaylightSavingTime
property:
Gets a value indicating whether the time zone has any daylight saving time rules.
So, it doesn't tell you if the time zone currently uses daylight saving time or not, it tells you if it ever has, at least within the brief history of time that is in the Windows time zone data.
If you want to know if DST is currently in effect, then do:
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("W. Australia Standard Time");
tzi.IsDaylightSavingTime(DateTime.UtcNow) // false
And if you want to know if it is supported at any time in a particular year, you can examine the adjustment rule data returned from the GetAdjustmentRules
method.
Windows stores the time zone data in the registry at:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
\Time Zones\W. Australia Standard Time\Dynamic DST
So we can see that there is data from 2005 forward in the registry. If you look carefully, you can also see some variation between 2006 and 2009. This article can help you interpret the data, if you are interested.
Indeed, if we check timeanddate.com (a very good resource for time zone info), we can see that Western Australia did indeed have daylight saving time from 2006 to 2009:
Lastly, I'll add that the Windows time zone servicing team has gotten very good at staying on top of the world's changes to time zone data. You can monitor this blog for updates. In particular, they greatly expanded coverage and improved historical accuracy with the June 2016 update.
For Australia, the June 2016 update added two new time zones; one for Lord Howe Island (UTC+10:30 STD, UTC+11:00 DST), and one for the unofficial Central Western Time (UTC+08:45) used near Eucla, but no corrections were necessary for any of the standard mainland time zones.
来源:https://stackoverflow.com/questions/43403628/w-aus-standard-time-net-timezoneinfo-supportsdaylightsavingstime-issue