Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timezone wrong on Pacific Daylight Time #36

Open
fengmk2 opened this issue Jul 27, 2018 · 7 comments
Open

timezone wrong on Pacific Daylight Time #36

fengmk2 opened this issue Jul 27, 2018 · 7 comments
Assignees
Labels

Comments

@fengmk2
Copy link
Member

fengmk2 commented Jul 27, 2018

> new Date('2018-4-1 0:52:52').toString()
'Sun Apr 01 2018 00:52:52 GMT-0700 (Pacific Daylight Time)'
> new Date('2018-1-1 0:52:52').toString()
'Mon Jan 01 2018 00:52:52 GMT-0800 (Pacific Standard Time)'
@fengmk2 fengmk2 self-assigned this Jul 27, 2018
@fengmk2 fengmk2 added the bug label Jul 27, 2018
@fengmk2
Copy link
Member Author

fengmk2 commented Jul 27, 2018

0 'Mon Jan 01 2018 00:00:00 GMT-0800 (Pacific Standard Time)' ' -0800'
1 'Thu Feb 01 2018 00:00:00 GMT-0800 (Pacific Standard Time)' ' -0800'
2 'Thu Mar 01 2018 00:00:00 GMT-0800 (Pacific Standard Time)' ' -0800'
3 'Sun Apr 01 2018 00:00:00 GMT-0700 (Pacific Daylight Time)' ' -0700'
4 'Tue May 01 2018 00:00:00 GMT-0700 (Pacific Daylight Time)' ' -0700'
5 'Fri Jun 01 2018 00:00:00 GMT-0700 (Pacific Daylight Time)' ' -0700'
6 'Sun Jul 01 2018 00:00:00 GMT-0700 (Pacific Daylight Time)' ' -0700'
7 'Wed Aug 01 2018 00:00:00 GMT-0700 (Pacific Daylight Time)' ' -0700'
8 'Sat Sep 01 2018 00:00:00 GMT-0700 (Pacific Daylight Time)' ' -0700'
9 'Mon Oct 01 2018 00:00:00 GMT-0700 (Pacific Daylight Time)' ' -0700'
10 'Thu Nov 01 2018 00:00:00 GMT-0700 (Pacific Daylight Time)' ' -0700'
11 'Sat Dec 01 2018 00:00:00 GMT-0800 (Pacific Standard Time)' ' -0800'

@fengmk2
Copy link
Member Author

fengmk2 commented Jul 27, 2018

还跟年份有关。。。

> a = new Date('2013-3-10 2:21:21')
2013-03-10T10:21:21.000Z
> a.toString()
'Sun Mar 10 2013 03:21:21 GMT-0700 (Pacific Daylight Time)'
> b = new Date('2018-3-10 2:21:21')
2018-03-10T10:21:21.000Z
> b.toString()
'Sat Mar 10 2018 02:21:21 GMT-0800 (Pacific Standard Time)'

@fengmk2
Copy link
Member Author

fengmk2 commented Jul 27, 2018

Through 2006, the local time (PST, UTC−8) changed to daylight time (PDT, UTC−7) at 02:00 LST (local standard time) to 03:00 LDT (local daylight time) on the first Sunday in April, and returned at 02:00 LDT to 01:00 LST on the last Sunday in October.

@fengmk2
Copy link
Member Author

fengmk2 commented Jul 27, 2018

> new Date('2018-11-4 2:21:21').toString()
'Sun Nov 04 2018 02:21:21 GMT-0800 (Pacific Standard Time)'
> new Date('2018-11-3 2:21:21').toString()
'Sat Nov 03 2018 02:21:21 GMT-0700 (Pacific Daylight Time)'

> new Date('2018-3-10 2:21:21').toString()
'Sat Mar 10 2018 02:21:21 GMT-0800 (Pacific Standard Time)'
> new Date('2018-3-11 2:21:21').toString()
'Sun Mar 11 2018 03:21:21 GMT-0700 (Pacific Daylight Time)'

@fengmk2
Copy link
Member Author

fengmk2 commented Jul 27, 2018

变化规则好强大。。。

@fengmk2
Copy link
Member Author

fengmk2 commented Jul 27, 2018

https://baike.baidu.com/item/pdt%E6%97%B6%E9%97%B4/1155172

在2006年以及之前,美国太平洋时区总是于每年四月第一个星期日深夜二时正将本地时间(UTC−8)转成夏令时间(UTC−7) ,并于十月的最后一个星期日深夜二时正转回本地时间。
于2007年生效的2005年能源政策法案,决定了美国太平洋时区的夏令时间始于每年三月的第二个星期六深夜二时正,并终于每年十一月的第一个星期日深夜二时正。而加拿大亦跟随美国的夏令时间制度。
PDT转换成北京时间方法
PDT从每年3月的第二个星期日到11月的第一个星期日期间和北京时间差15小时,其余月份和北京时间差16小时 。例如Oct 02, 2009 at 07:00 PDT= Oct 02, 2009 at 22:00 Beijing Time (7+15=22)

@CoderSavior
Copy link

所以这是个bug吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants