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

Weird behavior with daylight saving rule #908

Closed
andywu0408 opened this issue Nov 9, 2020 · 2 comments
Closed

Weird behavior with daylight saving rule #908

andywu0408 opened this issue Nov 9, 2020 · 2 comments

Comments

@andywu0408
Copy link

andywu0408 commented Nov 9, 2020

var a = moment.tz('2018-10-05', 'America/Los_Angeles').format('z');
var b = moment.tz('2028-10-05', 'America/Los_Angeles').format('z');

console.log(a+", "+b) // should output "PDT, PDT". But my program outputs "PDT, PST", which is wrong. Why??

Both "a" and "b" should be "PDT", since both times are during daylight savings.

However, my program always output "PST" for b, does anyone happens to know why?

I'm using the newest versions:

  1. moment-timezone: "0.5.31"
  2. moment: "2.29.1"
@andywu0408
Copy link
Author

andywu0408 commented Nov 9, 2020

Could this be possibly related to Issue#798, Issue#881? I noticed that the wrong conversion of timezone abbreviation & offset only happens in a far future date like 2028 in my example (b).

@andywu0408
Copy link
Author

Solution: Changing data file to "moment-timezone-with-data.js" fixed the issue. Please refer to moment timezone's documentation.

I was using the data file "moment-timezone-with-data-10-year-range", which only supported years from 2012-2022. Thus, the year 2028 was not covered.

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

No branches or pull requests

1 participant