When trying to get Offset information from past date, TimeZoneInfo is returning wrong information only in Windows.
The following .NET code reproduce the issue:
let dt = DateTimeOffset.Parse("1904-05-11T08:45:30Z")
let timeZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/Madrid")
timeZone.GetUtcOffset(dt).Hours //Should be 0, but return 2 on Windows.
My hypothesis is that the timezone data in windows is not updated, but I did not found any way to update it manually.
There exists two major time zone databases:
- IANA
- Windows
They do not share the same time zone names, nor the same data. Although there is some somewhat ad-hoc mapping that can be done to translate a time zone name from one to another. Such a translation is generally pretty good, but not 100% accurate. Accuracy tends to degrade sharply with dates that are pre 1970.
.NET uses the Windows time zone database. This database has a 2h offset for your time and place.
Mac/Linux uses the IANA time zone database. This database has a 0h offset for your time and place.