• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

[复制链接]
菜鸟教程小白 发表于 2022-4-23 21:05:52 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

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...

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



Best Answer-推荐答案


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.

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap