Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
64 views
in Technique[技术] by (71.8m points)

javascript - Browsers, time zones, Chrome 67 Error (historic timezone changes)

I've updated Chrome to 67 version. And I get an error with the date

==============

Microsoft Edge 42.17134.1.0

new Date("1900-01-01T00:00:00").getTimezoneOffset() 

-180

new Date("2018-05-30T00:00:00").getTimezoneOffset()

-180

Microsoft Internet Explorer 11.48.17134.0

new Date("1900-01-01T00:00:00").getTimezoneOffset() 

-180


new Date("2018-05-30T00:00:00").getTimezoneOffset() 

-180

Mozilla Firefox 60.0.1

new Date("1900-01-01T00:00:00").getTimezoneOffset() 

-180

new Date("2018-05-30T00:00:00").getTimezoneOffset() 

-180

Chrome 67.0.3396.62

new Date("1900-01-01T00:00:00").getTimezoneOffset() 

-150

new Date("2018-05-30T00:00:00").getTimezoneOffset()

-180

======================

-150 in Chrome 67...

Another Example (Chrome 67):

new Date("1900-01-01T00:00:00");

Mon Jan 01 1900 00:00:00 GMT+0230 (Moscow Standard Time)

======================

With Chrome 67, time zones began incorrect (+0230, was: +0300)

Please Tell me?

What Can I Do ?

The situation is very important! All code I must to rewrite...

======================

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm going to assume you're in the Europe/Moscow time zone - that seems likely given the output you've provided.

In 1900, the Europe/Moscow time zone had an offset of +02:30:17, according to the IANA time zone database. Presumably Chrome is rounding down to 02:30 to avoid sub-minute offsets, but it's returning appropriate data as far as I can see. The offset in Russia first became a whole number of hours in 1919, at least according to the IANA database.

Arguably you should be asking why the other browsers are not doing that - but more likely, you should change your code to not ask for time zone information prior to 1970. The IANA database aims to provide accurate data from the Unix epoch onwards; anything earlier is very much "best effort". From the theory file:

Clock transitions before 1970 are recorded for each such location, because most systems support timestamps before 1970 and could misbehave if data entries were omitted for pre-1970 transitions. However, the database is not designed for and does not suffice for applications requiring accurate handling of all past times everywhere, as it would take far too much effort and guesswork to record all details of pre-1970 civil timekeeping. Although some information outside the scope of the database is collected in a file backzone that is distributed along with the database proper, this file is less reliable and does not necessarily follow database guidelines.

In terms of why you're seeing this with Chrome 67 if you weren't seeing it with previous versions of Chrome - I wonder whether Chrome has just started bundling IANA time zone data rather than using the OS data.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...