Search code examples
.nettimezonedst

.NET TimeZoneInfo wrong about Morocco daylight savings


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?


Solution

  • 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.