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

[bugfix] Fix #4390: use offset properly in toISOString #4391

Merged
merged 1 commit into from Mar 2, 2018

Conversation

Projects
None yet
3 participants
@ashsearle
Contributor

ashsearle commented Jan 4, 2018

Bug was introduced in PR #4341.

I thought unit-tests using utc() and utcOffset(...) were good enough, but the behaviour of moments in utc mode isn't the same as non-utc moments with local timezone offsets.

I'm not sure how to create unit-tests for this, but PR continues to keep unit-tests passing, and I've checked behaviour by using this bash script:

#!/bin/bash

moment=./build/umd/moment.js

for tz in Asia/Kathmandu America/Sao_Paulo Europe/London; do
echo $tz;
TZ=$tz node -e "$(cat << EOF
var moment = require('${moment}');
var m = moment();
console.log(m.toISOString());
console.log(m.toISOString(true));
EOF
)"
done

Output:

Asia/Kathmandu
2018-01-04T19:06:41.943Z
2018-01-05T00:51:41.943+05:45
America/Sao_Paulo
2018-01-04T19:06:42.071Z
2018-01-04T17:06:42.071-02:00
Europe/London
2018-01-04T19:06:42.202Z
2018-01-04T19:06:42.202+00:00

@ashsearle ashsearle changed the title from Fix #4390: use offset properly in toISOString to [bugfix] Fix #4390: use offset properly in toISOString Jan 4, 2018

@marwahaha marwahaha requested review from icambron and ichernev Jan 4, 2018

@icambron

This comment has been minimized.

Member

icambron commented Jan 4, 2018

Yeah, the fix makes sense. I say just merge it.

@marwahaha marwahaha merged commit b8bc835 into moment:develop Mar 2, 2018

5 checks passed

Base branch Looks good!
Generated files No edits to generated files! :)
Title Your title looks great!
continuous-integration/travis-ci/pr The Travis CI build passed
Details
licence/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment