Update 2998527 causes incorrect code lookups on past dates by using TimeZoneInfo in the .NET Framework
After October 26, 2014, applications that are hosted on systems that have the September 2014 Russian time zone update (KB 2998527) installed and that use the Microsoft .NET Framework might calculate time incorrectly when they use the TimeZoneInfo class.
This problem occurs in the following time zones:
- (UTC-04:30) Caracas
- (UTC+01:00) Windhoek
- (UTC+02:00) Kaliningrad (RTZ 1)
- (UTC+02:00) Tripoli
- (UTC+03:00) Minsk
- (UTC+03:00) Moscow, St. Petersburg, Volgograd (RTZ 2)
- (UTC+05:00) Ekaterinburg (RTZ 4)
- (UTC+06:00) Novosibirsk (RTZ 5)
- (UTC+07:00) Krasnoyarsk (RTZ 6)
- (UTC+08:00) Irkutsk (RTZ 7)
- (UTC+09:00) Yakutsk (RTZ 8)
- (UTC+10:00) Magadan
- (UTC+10:00) Vladivostok, Magadan (RTZ 9)
- (UTC+13:00) Samoa
This problem occurs because a change in the base offset of a time zone breaks any code in the affected time zones if that code looks up past dates by using TimeZoneInfo in the .NET Framework. This is because the .NET Framework cannot track year-to-year changes in the base offset.
This problem was exposed by the recent changes to Russian time zones that are described in Microsoft Knowledge Base article 2998527.
The .NET Framework previously ignored the UTC offset that is set in an internal adjustment rule. Instead, it used the base UTC offset in certain calculations. The .NET Framework also ignored adjustment rules that do not have daylight transitions.
This issue has been resolved not only in the most recently release of the .NET Framework, but also in the following KB articles:
|ID||Title||Target||Custom 01||KB article|
|1040166||[4.5.x] Russian time zone changes impact on .NET||.NET Framework 4.5/4.5.1/4.5.2||HR-1411||3011110|
|1065448||[3.5] Russian time zone changes impact on .NET||.NET Framework 3.5 SP1||HR-1411||3013380|
|1065447||[4.0] Russian time zone changes impact on .NET||.NET Framework 4||HR-1411||3012132|
|1104556||[4.0] Russian TZ update throws InvalidOperationException||.NET Framework 4||HR-1502||3031985|
|1104557||[3.5] Russian TZ update functional test failures||.NET Framework 3.5 SP1||HR-1502||3031989|
|1118018||[4.0] RU TimeZoneInfo issues on Server 2003 SP2||.NET Framework 4||HR-1504||3057756|
|1083122||DTS: [4.5.2] Incorrect results when serializing/de-serializing DateTime||.NET Framework 4.5/4.5.1/4.5.2||HR-1502||3026376|
|1083123||DTS: [4.0] Incorrect results when serializing/de-serializing DateTime||.NET Framework 4||HR-1502||3031985|
|1087142||DTS: [3.5] Incorrect results when serializing/de-serializing DateTime||.NET Framework 3.5 SP1||HR-1502||3031989|
|1083122||OnDemand: Russian TZ - Part2 - NDP 4.5.1/4.5.2 RTM - Win8.1RTM/Win2K12R2RTM/WinRT8.1RTM - KB3018511||.NET Framework 4.5/4.5.1/4.5.2||OnDemand||3018511|
Consider the following C# example code:
For example, before you apply the KB 2998527 update, this code correctly returns the date and time as June 1, 2013 at 04:00. After you apply the update, the code incorrectly returns the date and time as June 1, 2013 at 03:00.
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Russian Standard Time"); DateTime dt = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(2013, 6, 1), tz); Console.WriteLine(dt);
Article ID: 3012229 - Last Review: 06/20/2016 06:19:00 - Revision: 4.0
Microsoft .NET Framework 4.6, Microsoft .NET Framework 4.5.2, Microsoft .NET Framework 4.5.1, Microsoft .NET Framework 4.5, Microsoft .NET Framework 4, Microsoft .NET Framework 3.5, .NET Core 1.0