Can Luxon retrieve a list of all valid timezone names?
See original GitHub issueI’m trying to implement functionality in my app that allows the user to enter a local time, and then assign a custom timezone identifier for a different timezone (e.g. Asia/Ho_Chi_Minh
).
I’m doing this so that due dates/times can be entered relative to a remote location without the user having to manually calculate what the local time of their current location would be at that instant (and maybe get it wrong due to DST changes, etc.).
Luxon lets me retrieve the timezone identifier for the current location:
DateTime.local().zoneName
but I’m having a hard time establishing whether or not Luxon will allow me to retrieve an entire list of all valid identifiers. There’s no obvious API call in the docs for this, and I’m mindful that as Luxon calls on the browser, it most likely doesn’t maintain its own list internally.
Is there a means of achieving this through Luxon? If not, are there any alternative recommendations for this need?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:21 (2 by maintainers)
I’m managed to get the list of supported timezones (and later cache it) using tzdata library and the following code snippet:
Coming in from 2021 here to mention that getting a list of timezones would be useful, so we don’t need to copy from an external source, that source then needs to be updated and in sync with luxon, or use another external library which also needs to be in sync with luxon. Luxon already has the information (clearly, since it uses it) so not only should be be easy to add, but much lwoer file size than adding redundant data. Just my 2 cents, love luxon : )