moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.23k stars 730 forks source link

Inconsistent time zone conversions via the time zone functionality #1473

Open lemmylem opened 1 year ago

lemmylem commented 1 year ago

Describe the bug For some reason, Luxon is not converting to input time zone correctly. When I change my browser specific time zone and convert millisecond unix timestamp to an equivalent time in a different time zone, Luxon incorrectly converts these values. However, it's not only Luxon.

To Reproduce Please share a minimal code example that triggers the problem: See the codesbandbox: https://codesandbox.io/s/objective-pascal-tyc2mv?file=/src/DateTimePicker.js

1) Click that link above to the code sandbox 2) Download time zone changing extension: https://chrome.google.com/webstore/detail/change-timezone-for-googl/cejckpjfigehbeecbbfhangbknpidcnh 3) In the code sample, 1689620100000 translates to July 17, 21:55 for the Europe/Volgograd time zone (see: https://www.epochconverter.com/timezones?q=1689620100&tz=Europe%2FVolgograd). However, luxon library (and others I added for comparison), clearly display the wrong values (which changes depending on what time zone you choose via the extension) 4) Keep changing time zones and refreshing...you will see only the moment library displays the correct values, no matter which time zone you change the browser time zone to

Actual vs Expected behavior I expect Luxon to display the same exact time for a given time zone input no matter what I do to the browser local time. I expect it to behave just like the moment library does.

Desktop (please complete the following information):

diesieben07 commented 1 year ago

The chrome extension you are using does not properly handle DST zones. It only sets a fixed offset based on the zone you select and the current time. It does not actually set a real time zone. Therefor I assume it breaks some of the hacks Luxon uses to do time zone math. Can you reproduce this if you change your time zone properly, without this extension?