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

parseZone() not parsing UTC correctly #3463

Closed
sebastien-ma opened this issue Sep 23, 2016 · 6 comments · Fixed by #3581
Closed

parseZone() not parsing UTC correctly #3463

sebastien-ma opened this issue Sep 23, 2016 · 6 comments · Fixed by #3581
Labels

Comments

@sebastien-ma
Copy link

On latest version (2.15.1), parseZone() seems not working correctly when offset is utc.

moment.parseZone('2016-05-04T00:00:00Z').format()
=> "2016-05-04T08:00:00Z" bad

moment.parseZone('2016-05-04T00:00:00+08:00').format()
=> "2016-05-04T00:00:00+08:00" good

The method was good on 2.14.1, I recently updated moment.js to 2.15.1 and the new version failed my test case.

@maggiepint
Copy link
Member

Yep. That's wrong. I'll maybe see if I can't tackle that one tonight, I think I know where it happened.

@tlrobinson
Copy link

FYI this bug was introduced in the fix for #3083, b2ee2d4

@mfn
Copy link

mfn commented Oct 14, 2016

Is this maybe related? I tested with with 2.15.1 too:

t = moment().toISOString();
console.log(t.toString());
parsed = moment.parseZone(t);
console.log(parsed.toISOString());

Outputs:

2016-10-14T15:33:37.457Z
2016-10-14T17:33:37.457Z

My local time is "Europe/Vienna" and thus I know where the 2 hour difference probably comes from but I don't see why it should do it.

With 2.14.1 I get the expected output:

2016-10-14T15:36:23.956Z
2016-10-14T15:36:23.956Z

@wi-ski
Copy link
Contributor

wi-ski commented Oct 14, 2016

PR handles the issue I believe - #3504 - Please let me know if its just flat wrong. @maggiepint

@mfn
Copy link

mfn commented Oct 14, 2016

I can confirm that it fixes my problem from #3463 (comment)

@wi-ski
Copy link
Contributor

wi-ski commented Oct 15, 2016

#3504 just got labeled a bug fix w00t!

ichernev added a commit to ichernev/moment that referenced this issue Nov 8, 2016
ichernev added a commit that referenced this issue Nov 8, 2016
ichernev added a commit that referenced this issue Nov 12, 2016
[tests] Fixes #3463, parseZone not handling Z correctly (tests only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants