Skip to content

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.
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