W. Aus Standard Time .Net TimeZoneInfo SupportsDaylightSavingsTime Issue

后端 未结 1 1589
没有蜡笔的小新
没有蜡笔的小新 2021-01-28 04:54

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\'

1条回答
  •  伪装坚强ぢ
    2021-01-28 05:30

    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.

    0 讨论(0)
提交回复
热议问题