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

Wrong year calculation for ISO Dates before 1970 #1627

Closed
johann-sonntagbauer opened this issue Apr 27, 2014 · 6 comments
Closed

Wrong year calculation for ISO Dates before 1970 #1627

johann-sonntagbauer opened this issue Apr 27, 2014 · 6 comments
Labels

Comments

@johann-sonntagbauer
Copy link

When I try to parse ISO Dates before 1970 the year caluclation is wrong. It will add one year.

Which results in following very strange result:
moment('1970-01-01T00:00:00.000+01:00').isSame(moment('1969-01-01T00:00:00.000+01:00')) === true

used moment.version
"2.6.0"

@johann-sonntagbauer
Copy link
Author

some additional details:

moment('1969-01-01T00:00:00.000+01:00').year()
1970

moment('1969-01-01T00:00:00.000').year()
1969
moment('1969-01-01T00:00:00.000+02:00').year()
1969

So the problem only exists when the timezone is the same as the actual browser timezone it seems.

@ichernev
Copy link
Contributor

ichernev commented May 8, 2014

Are you on safari? Also what is your location (timezone, language).

@ichernev
Copy link
Contributor

ichernev commented May 8, 2014

Ahh, you're right. This is happening because of a weird interplay between Date bug workaround (manually set the year if < 1970), and timezone and year shift because of it (because 1st jan 00:00 +1, is actually 31 Dec last year in local time).

I guess we need to rethink the way timezones are parsed. First parse, then verify, then apply offset.

@johann-sonntagbauer
Copy link
Author

sounds reasonable 👍
Sorry but I can't give any advice here, tried to understand the logic a little but I gave up.

@ichernev
Copy link
Contributor

ichernev commented May 8, 2014

The pr would fix it in next release dont worry. Thank you for reporting

@icambron
Copy link
Member

icambron commented Jul 2, 2014

Fixed by #1651. @ichernev writes the code, I close the tickets.

@icambron icambron closed this as completed Jul 2, 2014
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

3 participants