问题
Disclaimer
While this question looked like a potential duplicate, it was resolved by referring to IsAmbiguousTime. This does not solve my problem, as the time where I'm noticing discrepancies is not reported to be ambiguous.
The question, then...
While timeanddate.com says Morocco observes daylight savings between April 3 and July 31 this year, and the current time as provided by worldtimeserver.com seems to imply that this is the case, the .NET TimeZoneInfo does not report Casablanca time as either having any AdjusmentRules or AmbiguousTimeOffsets relevant to the year 2011.
Indeed, setting my computer's clock to Casablanca time, it will set the current time to one hour earlier than what is cited as the current time in Casablanca by online resources.
Is the .NET library inaccurate in this regard, or are all other sources at fault? Given that the .NET library is the inaccurate source here, is this a common problem? The fact that I found out about this instance simply because the discrepancy occurred in the first time zone in the .NET enumeration is unsettling. Is this based on a local database that I can keep updated myself?
回答1:
As noted in the MSDN entry for TimeZoneInfo.GetSystemTimeZones, .NET gets its information from the registry. Searching Microsoft Support for DST shows a pretty active history of time zone updates. Unfortunately, there have been no Casablanca updates since December, and the December update sounds like it removed daylight savings settings for Morocco.
回答2:
It looks like Morocco may have decided to drop DST after this year. Microsoft seems to have jumped the gun and removed DST early.
If you look at this link, notice that they say there are no DST changes for 2012 onward.
http://www.timeanddate.com/worldclock/timezone.html?n=60
As DocMax says, DST is calculated from the OS, so this is not a .NET issue. It's a windows issue.
回答3:
Latest update: From Microsoft Tech Community
The November 2018 update addresses Daylight Standard Time (DST) changes for the Kingdom of Morocco and Volgograd, Russia.
The Kingdom of Morocco has decided to remain permanently on UTC+01:00, instead of returning to UTC+00:00 on October 28, 2018, as previously communicated.
Also:
To reflect these changes, Windows 10 customers should ensure they have the latest updates installed. Windows 10 Update
来源:https://stackoverflow.com/questions/5562966/net-timezoneinfo-wrong-about-morocco-daylight-savings