{"id":298711,"date":"2020-02-14T15:00:38","date_gmt":"2020-02-14T15:00:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298711"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298711","title":{"rendered":"\u0418 \u0441\u043d\u043e\u0432\u0430 \u043e\u0431 \u00abIncorrect time zone information for Russian time zones \u00bb [.Net bug, ID: 693286]"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488366\/\">\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u043a\u043e\u043b\u043b\u0435\u0433\u0438, \u0441\u043f\u0435\u0448\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0435\u0439 \u043f\u0440\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 Java \u0438 .Net \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. \u0414\u043b\u044f \u043f\u0443\u0449\u0435\u0439 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440: .Net \u0441\u0435\u0440\u0432\u0438\u0441 \u0447\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u044b\u0435 \u0442\u0438\u043f\u0430 Date \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u0438\u0445 \u0432 \u0442\u0438\u043f long \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 Java consumer&#8217;a, \u0433\u0434\u0435 \u0443\u0436\u0435 \u0438\u0437 long \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 java.util.Date. \u0412\u0441\u0451 \u0431\u044b \u043d\u0438\u0447\u0435\u0433\u043e, \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0432\u044b\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u043e\u0439 \u043e\u0442\u043c\u0435\u043d\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430 \u0437\u0438\u043c\u043d\u0435\u0435-\u0438\u043b\u0438-\u0443\u0436-\u043a\u0430\u043a\u043e\u0435-\u0442\u0430\u043c-\u0432\u0440\u0435\u043c\u044f. .Net \u0441\u0435\u0440\u0432\u0438\u0441 (\u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u0439 time-zone) \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0434\u0430\u0442\u0443 (\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 long) \u0434\u043b\u044f \u00ab01\/01\/2010 13:00:00\u00bb, \u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Java \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441 java.util.Date \u043a\u0430\u043a \u00ab01\/01\/2010 12:00:00\u00bb. \u041e\u0442\u043a\u0443\u0434\u0430 \u044d\u0442\u0430 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0447\u0430\u0441 ?! \u041d\u0430\u0447\u0438\u0430\u0435\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0418\u0442\u0430\u043a, Java code:  <\/p>\n<pre><code class=\"java\">public class Main {      public static void main(String[] args) throws ParseException {         SimpleDateFormat format = new SimpleDateFormat(&quot;yyyy-MM-dd'T'HH:mm:ss&quot;);         TimeZone tzMoscow = TimeZone.getTimeZone(&quot;Europe\/Moscow&quot;);         TimeZone tzLondon = TimeZone.getTimeZone(&quot;Europe\/London&quot;);          System.out.println(&quot;Before Medvedev tricks: &quot; + calcTimeZoneShift(tzLondon, tzMoscow, &quot;2010-01-01T13:00:00&quot;, format));         System.out.println(&quot;After Medvedev tricks: &quot; + calcTimeZoneShift(tzLondon, tzMoscow, &quot;2013-01-01T13:00:00&quot;, format));     }      static private long calcTimeZoneShift(TimeZone tz1, TimeZone tz2, String time, SimpleDateFormat format)             throws ParseException{          format.setTimeZone(tz1);         Date date1 = format.parse(time);          format.setTimeZone(tz2);         Date date2 = format.parse(time);         return (date1.getTime() - date2.getTime())\/3600000;      };  } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"dos\">Output: Before Medvedev tricks: 3 After Medvedev tricks: 4 <\/code><\/pre>\n<p>  \u0412\u0440\u043e\u0434\u0435 \u0432\u0441\u0435 \u0432\u0435\u0440\u043d\u043e: \u0434\u043e \u041c\u0435\u0434\u0432\u0435\u0434\u0435\u0432\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0437\u0438\u043c\u043e\u0439 \u0438 \u043b\u0435\u0442\u043e\u043c \u0441 \u041b\u043e\u043d\u0434\u043e\u043d\u043e\u043c \u0431\u044b\u043b\u0430 \u0432 3 \u0447\u0430\u0441\u0430, \u0430 \u0432\u043e\u0442 \u043f\u043e\u0441\u043b\u0435 \u041c\u0435\u0434\u0432\u0435\u0434\u0435\u0432\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0437\u0438\u043c\u043e\u0439 \u0443\u0436\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 4 \u0447\u0430\u0441\u0430.<\/p>\n<p>  \u0427\u0435\u043c \u0436\u0435 \u043d\u0430\u0441 \u0443\u0434\u0438\u0432\u0438\u0442 .Net:<\/p>\n<pre><code class=\"plaintext\">namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {                          TimeZoneInfo tzMoscow = TimeZoneInfo.FindSystemTimeZoneById(&quot;Russian Standard Time&quot;);             TimeZoneInfo tzLondon = TimeZoneInfo.FindSystemTimeZoneById(&quot;GMT Standard Time&quot;);                          System.Diagnostics.Debug.WriteLine(&quot;Before Medvedev tricks: &quot; + calcTimeZoneShift(tzLondon, tzMoscow, &quot;01\/01\/2010 13:00:00&quot;));             System.Diagnostics.Debug.WriteLine(&quot;After Medvedev tricks: &quot; + calcTimeZoneShift(tzLondon, tzMoscow, &quot;01\/01\/2013 13:00:00&quot;));          }          private static long calcTimeZoneShift(TimeZoneInfo tz1, TimeZoneInfo tz2, String time)         {             DateTime date = DateTime.Parse(time);             DateTime newTime = TimeZoneInfo.ConvertTime(date, tz1, tz2);             return (newTime.ToFileTimeUtc() - date.ToFileTimeUtc()) \/ 36000000000;         }      } } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"dos\">Output: Before Medevedev tricks: 4 After Medevedev tricks: 4 <\/code><\/pre>\n<p>  \u041c\u043b\u0438\u0438\u0438\u043d, \u0432\u043e\u0442 \u044d\u0442\u043e \u0434\u0430 ?! \u0422\u043e \u0435\u0441\u0442\u044c timezone shift \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u043a\u0430\u043a \u00ab\u0434\u043e\u00bb, \u0442\u0430\u043a \u0438 \u00ab\u043f\u043e\u0441\u043b\u0435\u00bb. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c google-\u0438\u0442\u044c \u0438 <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb382058.aspx\" rel=\"nofollow\">\u043d\u0430\u0445\u043e\u0434\u0438\u043c<\/a>:<\/p>\n<blockquote><p>Incorrect time zone information for Russian time zones by \u0411\u0440\u043e\u043d\u043d\u0438\u043a\u043e\u0432 \u041f\u0430\u0432\u0435\u043b<\/p>\n<p>  Type: Bug<br \/>  ID: 693286<br \/>  Opened: 10\/5\/2011 8:18:45 PM<br \/>  Access Restriction: Public<br \/>  Moderator Decision: Sent to Engineering Team for consideration<\/p>\n<p>  Time zone information for Russian time zones is incorrect. I think this occurs after Russian government disable summer time. Issue occurs then I converting date in the past from UST time zone to one of Russian time zones using routine TimeZoneInfo.ConvertTimeFromUtc<br \/>  Actual results<br \/>  UTC 13.06.2010 00:00:00 = Moscow 13.06.2010 5:00:00<br \/>  UTC 13.12.2010 00:00:00 = Moscow 13.12.2010 4:00:00<\/p>\n<p>  Expected results<br \/>  UTC 13.06.2010 00:00:00 = Moscow 13.06.2010 4:00:00<br \/>  UTC 13.12.2010 00:00:00 = Moscow 13.12.2010 3:00:00<\/p><\/blockquote>\n<p>  \u0427\u0438\u0442\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442:<\/p>\n<blockquote><p>In short, the issue is not caused by a problem with the .NET framework. Instead, it is caused by an OS update that affected registry data describing some Russian time zones. The background is that Russia has changed its time zones, as well as their base offsets and DST rules all in the same year.<\/p><\/blockquote>\n<p>  \u0418 \u043a\u0430\u043a \u0436\u0435 \u0442\u0430\u043a, \u0443 \u043c\u0435\u043d\u044f Windows 7, \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u043f\u0430\u043a\u0438 \u0438 \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f .Net \u0438 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043e\u0448\u0438\u0431\u043a\u0430, \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0432 2011 \u0433\u043e\u0434\u0443 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435 \u0440\u0435\u0448\u0435\u043d\u0430 ?! \u041b\u0430\u0434\u043d\u043e\u0435 \u043f\u0443\u0441\u0442\u043e\u0435 \u044d\u0442\u043e \u0432\u0441\u0435 (\u044f \u043f\u0440\u043e \u0432\u043e\u043f\u043b\u0438 \u0438 \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e \u0432 Java \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u00ab\u043a\u0430\u043a \u043d\u0430\u0434\u043e\u00bb)\u2026 \u041f\u0440\u043e\u0441\u0442\u043e \u0443\u0447\u0442\u0438\u0442\u044b\u0432\u0430\u0439\u0442\u0435 \u044d\u0442\u043e\u0442 \u0431\u0430\u0433 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u0443\u0436 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/488366\/\"> https:\/\/habr.com\/ru\/post\/488366\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/488366\/\">\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u043a\u043e\u043b\u043b\u0435\u0433\u0438, \u0441\u043f\u0435\u0448\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0435\u0439 \u043f\u0440\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 Java \u0438 .Net \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. \u0414\u043b\u044f \u043f\u0443\u0449\u0435\u0439 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440: .Net \u0441\u0435\u0440\u0432\u0438\u0441 \u0447\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u044b\u0435 \u0442\u0438\u043f\u0430 Date \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u0438\u0445 \u0432 \u0442\u0438\u043f long \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 Java consumer&#8217;a, \u0433\u0434\u0435 \u0443\u0436\u0435 \u0438\u0437 long \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 java.util.Date. \u0412\u0441\u0451 \u0431\u044b \u043d\u0438\u0447\u0435\u0433\u043e, \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0432\u044b\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u043e\u0439 \u043e\u0442\u043c\u0435\u043d\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430 \u0437\u0438\u043c\u043d\u0435\u0435-\u0438\u043b\u0438-\u0443\u0436-\u043a\u0430\u043a\u043e\u0435-\u0442\u0430\u043c-\u0432\u0440\u0435\u043c\u044f. .Net \u0441\u0435\u0440\u0432\u0438\u0441 (\u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u0439 time-zone) \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0434\u0430\u0442\u0443 (\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 long) \u0434\u043b\u044f \u00ab01\/01\/2010 13:00:00\u00bb, \u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Java \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441 java.util.Date \u043a\u0430\u043a \u00ab01\/01\/2010 12:00:00\u00bb. \u041e\u0442\u043a\u0443\u0434\u0430 \u044d\u0442\u0430 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0447\u0430\u0441 ?! \u041d\u0430\u0447\u0438\u0430\u0435\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-298711","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298711","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=298711"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298711\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}