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

Fix for add/subtract when crossing a tz offset #53

Merged
merged 1 commit into from
Feb 6, 2014

Conversation

kroo
Copy link
Contributor

@kroo kroo commented Jan 15, 2014

When using 'add' or 'subtract' (or maybe other) moment.js functions, result was wrong if date passes through tz offset change. See discussion in issue #28 for more details.

This commit includes a small suite of tests, along with a small fix in the spirit of that suggested by @icambron here: "If we're changing a date or month, just [...] change the offset without touching the time."

This requires an associated change to the moment project (moment/moment#1419), to support this second argument (though it will not fail any harder than it currently does, if running with an older version of moment).

When using 'add' or 'subtract' (or maybe other) moment.js functions, result was wrong if date passes through tz offset change.  See discussion in issue moment#28 for more details.

This commit includes a small suite of tests, along with a small fix in the spirit of that suggested by @icambron [here][1]: "If we're changing a date or month, just [...] change the offset without touching the time."

[1]: moment#28 (comment)

This requires an associated change to the moment project, to support this second argument (though it will not fail any harder than it currently does, if running with an older version of moment).
kroo added a commit to kroo/moment that referenced this pull request Jan 15, 2014
This adds a second argument to setters that provides a hint to updateOffset to not change hours/minutes when crossing a tz boundary.  This is frequently desirable when modifying part of an existing moment object directly.

It further passes this argument whenever adding / subtracting days or months, fixing an issue with moment-timezone (moment/moment-timezone#28).  See the corresponding PR for moment-timezone here: moment/moment-timezone#53.
ichernev added a commit that referenced this pull request Feb 6, 2014
Fix for add/subtract when crossing a tz offset

The tests would pass with moment version after (not including) 2.5.1.
@ichernev ichernev merged commit 0fa84a4 into moment:master Feb 6, 2014
ichernev pushed a commit to moment/moment that referenced this pull request Feb 6, 2014
This adds a second argument to setters that provides a hint to updateOffset to not change hours/minutes when crossing a tz boundary.  This is frequently desirable when modifying part of an existing moment object directly.

It further passes this argument whenever adding / subtracting days or months, fixing an issue with moment-timezone (moment/moment-timezone#28).  See the corresponding PR for moment-timezone here: moment/moment-timezone#53.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants