function isDST(d) {
let jan = new Date(d.getFullYear(), 0, 1).getTimezoneOffset();
let jul = new Date(d.getFullYear(), 6, 1).getTimezoneOffset();
return Math.max(jan, jul) !== d.getTimezoneOffset();
}
I can use the above to get if current time currently applying the DST, but I would like a function where I can enter the time zone and get what is the offset that needs to be applied when DST is true. So basically most of the time it's +1 hour, and in all situation it's "+ some value", but I would like to know the value that needs to be applied when DST is true.
I need the offset.
moment.tz([2012, 0], 'America/Los_Angeles').format('Z');
-08:00
moment.tz([2012, 5], 'America/Los_Angeles').format('Z');
-07:00
-7 - -8 = +1 so the DST offset is 1 hour, but I can't use this example, because DST applies during different times depending on the region.