Time difference between chrome / edge on windows 10

别等时光非礼了梦想. 提交于 2019-12-08 06:40:03

问题


I get TZ difference on windows 10 between Chrome and Edge. When I run this code in the console:

> var date = new Date(2013, 2, 29, 1, 0, 0, 0);
> date

This will be the output when running in on Edge

> [date] Fri Mar 29 2013 01:00:00 GMT+0200 (Jerusalem Standard Time)

While This will be the output on Chrome:

> [date] Fri Mar 29 2013 01:00:00 GMT+0300 (Jerusalem Daylight Time)

It seems that in Chrome it is recognise as DST but in Edge it doesn’t, which is correct.
(Attached screenshot)

If I turn off the “Adjust for day light saving time automatically” configuration - Chrome date becomes the same. (image2)

Someone, can explain why? and how to get the correct TZ in chrome in any "Date and Time" configuration?

Edge version: 20.10240.16384.0 Chrome version: 56.0.2924.75 (64-bit)


回答1:


This indeed appears to be a bug.

The TZ Database shows:

# As of 2013, DST starts at 02:00 on the Friday before the last Sunday
# in March.  DST ends at 02:00 on the last Sunday of October.

# Rule  NAME  FROM  TO   TYPE  IN   ON       AT    SAVE  LETTER/S
Rule    Zion  2013  max  -     Mar  Fri>=23  2:00  1:00  D
Rule    Zion  2013  max  -     Oct  lastSun  2:00  0     S

# Zone    NAME            GMTOFF    RULES   FORMAT  [UNTIL]
Zone    Asia/Jerusalem    2:20:54   -       LMT     1880
                          2:20:40   -       JMT     1918    # Jerusalem Mean Time?
                          2:00      Zion    I%sT

Therefore, in 2013, DST should have started on the Friday before the last Sunday in March, which was March 29. (The previous Friday was March 22, which doesn't meet the Fri>=23 rule in the time zone data.) This is date is also corroborated by timeanddate.com.

Windows appears to have this data correct. Examining the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Israel Standard Time\Dynamic DST

The last part I highlighted in green is the DST start date.

00 00 = Year        (ignored)
03 00 = Month       (March)
05 00 = Day of week (Friday)
05 00 = Day number  (5 = last)
02 00 = Hour        (02:00)
00 00 = Minute
00 00 = Second
00 00 = Millisecond

So both the Windows and the IANA data are pointing at the same date. Yet somehow Chrome is getting it wrong.

I also tested FireFox, which also appears to be getting it wrong:

I can also reproduce these results in Node.js.

But yes, Edge is getting it correct:

Do note that the browsers also differ in which direction they adjust a local time that falls into the "gap" created by the spring-forward transition. This is expected, and is being worked on in for a future version the of ECMAScript spec.

I don't work on the actual implementation within these browsers, but my understanding is that both Chrome, Node, and FireFox rely on ICU for their time zone internals. My guess is that it is an ICU bug that is being exposed here. Update: It appears to be a bug in the Microsoft C/C++ Runtime. I'm working on getting it to the right folks.

As far as what to do about it - if accurate historical time zone data is essential to your application, I strongly suggest you not rely on the environment to provide it, but bring it yourself using one of the libraries I listed here, such as moment-timezone (which I help maintain).



来源:https://stackoverflow.com/questions/41967837/time-difference-between-chrome-edge-on-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!