Closed JulianKingman closed 3 years ago
The way to do this would be to create a new subclass of Zone that uses the IANA database. You could do this almost completely outside of Luxon; the only change would be to allow the user to inject a function to use when creating the zone from a string. It would probably be around 4 lines of code in Luxon, and the zone implementation that supports parsing the zone file and using it in offset computations would go in a separate package.
I'm going to close this. I'll certainly accept a PR making the Zone factory pluggable. Something like:
Settings.ianaFactory = (zoneName) => IANAZone.create(zoneName) ;
And then call that function from here: https://github.com/moment/luxon/blob/91c5f87e7eed66f09165419455f47809990bd4f8/src/impl/zoneUtil.js#L25
Then a caller can import a new function from this other package and override that setting with it.
However, since that other package doesn't exist yet (I am not going to write it), it's a little academic at this point. If someone does write it, I'll be happy to support their efforts to make it play well in Luxon.
Is your feature request related to a problem? Please describe. Our server uses timezone db version 2020a, if the browser uses a different version and we try to save it to our back-end, we will get errors.
Describe the solution you'd like Provide something like
luxon.setTimezoneDB(require(IANA202a.json))
Describe alternatives you've considered An alternative would be to set it directly by modifying/ammending/overriding the Intl object, but I couldn't find examples of anyone doing this.
Additional context This would also solve some of the many timezone related tickets, as people could pin their timezones to a specific version. Here are some from the first 3 pages of issues: https://github.com/moment/luxon/issues/912 https://github.com/moment/luxon/pull/918 https://github.com/moment/luxon/issues/916 https://github.com/moment/luxon/issues/860 https://github.com/moment/luxon/issues/825 https://github.com/moment/luxon/issues/689 (maybe?)
If Luxon was to use specific IANA db versions instead of relying on the browser/environment version, then probably all of the timezone issues could be easily fixed.