moment / luxon

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

Wrong offsets for some timezones #1380

Closed Lafaiet closed 1 year ago

Lafaiet commented 1 year ago

For the following timezones: Antarctica/Casey, America/Whitehorse, America/Dawson, Asia/Amman, America/Chihuahua, America/Ojinaga, Europe/Volgograd, Africa/Juba, Asia/Damascus, Pacific/Apia, luxon appears to be using a wrong offset when creating an object with fromISO with zone parameter or when calling setZone.

luxon.DateTime.utc().setZone('Antarctica/Casey').toISO()

should result in something like 2023-02-13T19:50:30.878+08:00, but offset should have been +11

icambron commented 1 year ago

@Lafaiet I didn't check the others, but in Node 19, Antarctica/Casey works like you expect:

DateTime.utc().setZone('Antarctica/Casey').toISO()   // => '2023-02-14T08:22:27.241+11:00'             

Luxon is only as good as the environment's time zone data, which comes from ICU. My guess is that your build of Node 14 has bad or missing data. You can test this directly by cutting Luxon out of it:

new Intl.DateTimeFormat("en", { timeZone: "Antarctica/Casey", hour: "2-digit", minute: "2-digit", hourCycle: "h23", timeZoneName: "short" }).format()  //=> '08:29 GMT+11' 

I suspect you'll get a different answer there to. If so, you can fix this by either upgrading Node (this works because newer pre-built images of Node are built with newer versions of the ICU) or building Node 14 with a newer version of the ICU data.

Lafaiet commented 1 year ago

Thanks for your response @icambron!

You're totally right. Testing it with node version 14.21.2 does not give me the same issue :) I just still tricks me that moment js behaves as expected even with node 14.0.0