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 issue 261. #267

Closed
wants to merge 1 commit into from
Closed

Conversation

damienwhaley
Copy link

It appears when you are working with two moment objects and you take the diff, the input moment's _isUTC is ignored when you parse the input into inputMoment. I've done a check to see if it looks like a moment object (by checking the _isUTC to see if it is defined) and if it is, then it just copies the input rather than parsing it. I think it should work fine on regular date objects as there is no _isUTC member.

…jects and you take the diff, the input moment's _isUTC is ignored when you parse the input into inputMoment. I've done a check to see if it looks like a moment object (by checking the _isUTC to see if it is defined) and if it is, then it just copies the input rather than parsing it. I think it should work fine on regular date objects as there is no _isUTC member.
@@ -614,7 +614,7 @@
},

diff : function (input, val, asFloat) {
var inputMoment = moment(input),
var inputMoment = (moment._isUTC === undefined) ? moment(input) : input,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might mean input._isUTC instead of moment._isUTC. The moment global does not have an _isUTC flag on it, only instances have the flag. There is a function available if you want to typecheck moment instances, moment.isMoment. However, you said that a moment's _isUTC flag is ignored when you call the moment function on it. Maybe the true bug lies in the moment function.

@timrwood
Copy link
Member

timrwood commented Apr 8, 2012

Yeah, I agree, if moment(moment.utc()) isn't copying the _isUTC flag, then that is where it should be fixed.

https://github.com/timrwood/moment/blob/71eda19de4a277b76419d18f233ac4877bf801f2/moment.js#L416 should change to something like this:

var isUTC;
...
if (moment.isMoment(input)) {
    date = new Date(+input._d);
    isUTC = input._isUTC;
}
...
return new Moment(date, isUTC);

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 this pull request may close these issues.

3 participants