I use the moment-timezone v.0.5.3-2016c
library to calculate the UTC offset for a timezone:
var z = moment().tz("America/Los_Angeles");
z.utcOffset(); // -420 mins or -7 hours
// check if DST is shifted
z.isDSTShifted(); // false
But here https://en.wikipedia.org/wiki/List_of_tz_database_time_zones the UTC offset for the America/Los_Angeles
is -8 hours.
Moment uses the tzdb v.2016c and the wikipedia article too.
Well, why there are two different results here? And which result is right?
P.S.: there is the same difference for America/Kentucky/Monticello
and Europe/Tiraspol
, as well.
-7
is the correct answer at the present time (29 April 2016). The question is why the Moment.isDSTOffset()
routine doesn't know that. I think it has something to do with how Moment gets possession of the Date value; if it comes from a native Date object, it may not be able to tell. – Pointy Apr 29 '16 at 13:55moment("20160101").tz("America/Los_Angeles").utcOffset()
works as expected. – Sergey Apr 29 '16 at 14:18