0

When I'm converting a DateTime value to UTC it seems to be using the wrong offset for certain dates.

Example:

var input = new DateTime(1953, 04, 01, 00, 0, 0, 0);

var convertedDateTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(input, "Central European Standard Time", "UTC");

In this case the date is converted from 1953-04-01 00:00:00 to 1953-03-31 22:00:00. However according to https://www.timeanddate.com/worldclock/converter.html?iso=19530331T230000&p1=16&p2=1440 the output value should be 1953-03-31 23:00:00.

To me it looks like it's using the offset that is used today (2 hours) instead of the offset that was correct at that date (1 hour).

Am I making a mistake in the conversion?

user369117
  • 775
  • 1
  • 8
  • 19
  • 1
    Does this answer your question? [Does .NET have the history of time zone changes?](https://stackoverflow.com/questions/26156260/does-net-have-the-history-of-time-zone-changes) `TimeZoneInfo` relies on the system's time zone database. Windows doesn't go back to 1953 since there was no Windows back in 1953, so it has no reason to keep that data. For that you'll need a library dedicated to sorting out the historical mess that is DST adjustments. – Jeroen Mostert Oct 07 '21 at 11:00
  • [IANA's zoneinfo database](https://www.iana.org/time-zones) has timezone transitions for `Europe/Moscow` going back to the beginning of the 20th century. You should seek out a dotnet library using that database. The web site converter you mention uses that database. – O. Jones Oct 07 '21 at 11:15
  • Thank you. Basdd on the comments I tried NodaTime, because that does have the timezone database in it. – user369117 Oct 07 '21 at 18:36
  • And do not use standard libraries for old times (older then 1970). New zoneinfo database may lose such information (and use historical data from a wrong country – Giacomo Catenazzi Oct 08 '21 at 07:02

0 Answers0