moment / luxon

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

Invalid time zone specified: Pacific/Kanton #1240

Closed roman-suru closed 2 years ago

roman-suru commented 2 years ago

Describe the bug

"message": "Invalid time zone specified: Pacific/Kanton",
"stack": "RangeError: Invalid time zone specified: Pacific/Kanton\n    at new DateTimeFormat (<anonymous>)\n    at makeDTF (/opt/nodejs/node_modules/luxon/build/node/luxon.js:1271:22)\n    at IANAZone.offset (/opt/nodejs/node_modules/luxon/build/node/luxon.js:1439:17) ...

To Reproduce

return { 'Pacific/Kanton', utc_offset: IANAZone.create('Pacific/Kanton').offset(Date.now()) }

Actual vs Expected behavior A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

Additional context I searched the internet and found that this user faced a similar problem.

icambron commented 2 years ago

What browser? The zones are provided by the Intl API, implemented by the native JS libraries. If you run a browser or Node that doesn't support that zone, you get an error.

I tested Pacific/Kanton on Chrome 103 on MacOs, worked fine. However, it appears to be a relatively recent addition, about a year old: https://mm.icann.org/pipermail/tz/2021-May/030140.html. It's likely that you are just running in an environment that doesn't (yet) support that zone identifier. The workaround would be to use Pacific/Enderbury instead

roman-suru commented 2 years ago

Hi there, thanks for the reply. It was no browser but the node 14 runtime for AWS lambdas. Seems likely that it might not support this zone yet.