moment-timezone icon indicating copy to clipboard operation
moment-timezone copied to clipboard

isUTC() returning true erroneously

Open mattjohnsonpint opened this issue 8 years ago • 8 comments

Consider:

moment.tz("2016-01-01", "Europe/London").isUTC()  // true, should be false

mattjohnsonpint avatar Mar 10 '16 06:03 mattjohnsonpint

why should it be false?

Changron avatar Apr 07 '16 15:04 Changron

This moment is in London time. While London time is in line with UTC for part of the year, due to BST that is not always the case. While the Moment has the same offset as UTC (+00:00), it is not in fact IN UTC.

maggiepint avatar Apr 07 '16 16:04 maggiepint

Sort of. To be technically accurate, London is never on UTC. For part of the year it's on GMT, which just happens to be aligned with UTC+0. Though they would give the same value, it's technically not UTC.

Another way to think about it is, UTC is the same everywhere, all over the planet. It does not have any locality. We may tend to think about it as being at the prime meridian, but I can use UTC in China or in America and it's still UTC.

Arguing semantics, I know. But seems relevant for this particular discussion. :smile:

mattjohnsonpint avatar Apr 08 '16 16:04 mattjohnsonpint

Really for our purposes, the main reason is because isUTC() === true would lead you to believe the value was in UTC mode, such as created with moment.utc(...) or converted to utc with .utc(), and that +00:00 was the offset for the entire year.

mattjohnsonpint avatar Apr 08 '16 16:04 mattjohnsonpint

Didn't mean to imply that London was on UTC. Meant to imply the opposite - that it's never in UTC, it's just the same as UTC sometimes.

Noticed that Microsoft does not seem to understand this: image

maggiepint avatar Apr 08 '16 16:04 maggiepint

Yeah, I really need to get them to change that to (UTC+00:00) in the display string. :wink:

mattjohnsonpint avatar Apr 08 '16 16:04 mattjohnsonpint

Ok, so now that moment/moment#3098 has been merged, let's address this, and also that formatting is now using Z instead of +00:00.

(BTW - the MS issue above will be fixed next month. :wink:)

mattjohnsonpint avatar May 10 '16 07:05 mattjohnsonpint

Central Time is showing up as _isUTC: true when created with moment.utc().

patrickehansen avatar Dec 06 '18 06:12 patrickehansen