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

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

Merged
merged 1 commit into from Mar 2, 2018

Conversation

ashsearle
Copy link
Contributor

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 Fix #4390: use offset properly in toISOString [bugfix] Fix #4390: use offset properly in toISOString Jan 4, 2018
@icambron
Copy link
Member

icambron commented Jan 4, 2018

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

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

Successfully merging this pull request may close these issues.

None yet

3 participants