moment / moment-timezone

Timezone support for moment.js
momentjs.com/timezone
MIT License
3.82k stars 835 forks source link

Incorrect offset noticed #1049

Closed adityapachpor978478 closed 1 year ago

adityapachpor978478 commented 1 year ago

I've prepared 2 demo for charts for "America/Los_Angeles" timezone, in 2022 when clocks are shifted forward, the adjustment can be seen in charts, however, for the same timezone in 2023, this adjustment is not visible.

Below snippets use getTimezoneOffset method which utilizes moment-timezone to get the timezoneoffset for each epoch. If we use console.log() statement to know the timezoneoffset calculated by moment0timezone, in 2022 it changes for '480' to '420' at 2AM but in 2023 it is '480' constant throughout. The clock forward reference links are also specified along with snippets.

2022 DST adjustment working fine, 2AM to 3AM span is not observed in chart On 13 March 2022, clock is turned forward 1 HR at 2AM https://www.timeanddate.com/time/change/usa/los-angeles?year=2022 https://jsfiddle.net/adityapachpor/waqbzuvk/1/

2023 DST adjustment is not working, 2AM to 3AM span observed in chart On 12 March 2023, clock is turned forward 1 HR at 2AM https://www.timeanddate.com/time/change/usa/los-angeles?year=2023 https://jsfiddle.net/adityapachpor/ge8wzykv/6/

In another way, epoch 1678615200000 is actually Sunday March 12, 2023 03:00:00 (am) in time zone America/Los Angeles (PDT) but moment results in "Sun, Mar 12 2023 - 02:00" https://www.epochconverter.com/timezones?q=1678615200&tz=America%2FLos_Angeles https://jsfiddle.net/adityapachpor/abqsmu40/

gilmoreorless commented 1 year ago

Your JSFiddle snippets are using an outdated version of Moment Timezone (0.5.13). They're also using the files 2012-2022.min.js, which are deprecated. The clue's in the name of the file — they only cover dates up to 2022. :wink:

You should use https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.41/moment-timezone-with-data-10-year-range.min.js instead