1

From https://msdn.microsoft.com/en-us/library/bb397769(v=vs.110).aspx

The TimeZoneInfo.ConvertTimeToUtc(DateTime) method does not necessarily produce results that are identical to the TimeZone.ToUniversalTime and DateTime.ToUniversalTime methods. If the host system's local time zone includes multiple adjustment rules, TimeZoneInfo.ConvertTimeToUtc(DateTime) applies the appropriate rule to a particular date and time. The other two methods always apply the latest adjustment rule.

Please can someone explain this more clearly, preferably with examples?

cja
  • 9,512
  • 21
  • 75
  • 129
  • 1
    http://stackoverflow.com/questions/1704780/what-is-the-difference-between-datetime-touniversaltime-and-timezoneinfo-convert – Soner Gönül Jul 04 '15 at 11:48

1 Answers1

3

"Multiple adjustment rules" applies to having different rules for different years. Pretty common, daylight savings time rules are political decisions that often change. The TimeZone class only applies the current rule, even to historical dates. TimeZoneInfo can know about rules that were in effect in the past.

This ultimately depends on a database that keeps track of those rules. You can have a look-see at it, fire up Regedit.exe on Windows and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. The "Israel Standard Time" key is an interesting one to peek at, their rules constantly change. Note the listed years in the Dynamic DST key. Compare to the Wikipedia article about it and note that it isn't complete, you'll see the mayhem before 2004 missing. As noted in the article, Microsoft gave up on trying to keep it accurate for a while.

In general, a machine needs to have Windows Update enabled to reliably keep track of rule changes.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536