Moment: parseZone() not parsing UTC correctly

Created on 23 Sep 2016  ·  6Comments  ·  Source: moment/moment

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.

Bug

Most helpful comment

3504 just got labeled a bug fix w00t!

All 6 comments

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

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

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

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

I can confirm that it fixes my problem from https://github.com/moment/moment/issues/3463#issuecomment-253836488

3504 just got labeled a bug fix w00t!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ninigix picture ninigix  ·  3Comments

slavafomin picture slavafomin  ·  3Comments

4rg0n picture 4rg0n  ·  3Comments

paulyoung picture paulyoung  ·  3Comments

benhathaway picture benhathaway  ·  3Comments