I've noticed that there are quite a few open issues that involve timezones (#385, #403, #532, #546, #552, #564, #582, & possibly more).
Almost all of these would be fixed with three changes:
- Use the IANA timezone database.
- Treat timezones differently based on their source, e.g. parsed from natural language or timezones supplied to the library as an option.
- Detect entirely relative times when parsing natural language and don't apply timezones to them. (And also add a matching boolean property to the output?)
Using the IANA timezone database would allow you to support longer timezone codes like "America/Los_Angeles" as well as correctly handle dates in the past when different daylight savings rules were in effect.
Separated timezone logic would resolve #564: CET would be handled with daylight savings if passed as part of the input string and handled as an absolute time if passed as a timezone. This would account for the common usage as well as the expectation of developers.
And not applying the timezone handling to relative times when unnecessary would prevent parsing issues related to relative times and timezones from even occurring in the first place.
After doing some research and experimentation I found the timezonecomplete library on npm and it seems to be exactly what would be needed to handle all of these issues. It would also be very nice to be able to outsource timezone logic to a dedicated library due to how complicated and prone to change it is.
I'm willing to open a PR (or several) for this, would just want to confirm how they should behave first.
I've noticed that there are quite a few open issues that involve timezones (#385, #403, #532, #546, #552, #564, #582, & possibly more).
Almost all of these would be fixed with three changes:
Using the IANA timezone database would allow you to support longer timezone codes like
"America/Los_Angeles"as well as correctly handle dates in the past when different daylight savings rules were in effect.Separated timezone logic would resolve #564: CET would be handled with daylight savings if passed as part of the input string and handled as an absolute time if passed as a timezone. This would account for the common usage as well as the expectation of developers.
And not applying the timezone handling to relative times when unnecessary would prevent parsing issues related to relative times and timezones from even occurring in the first place.
After doing some research and experimentation I found the timezonecomplete library on npm and it seems to be exactly what would be needed to handle all of these issues. It would also be very nice to be able to outsource timezone logic to a dedicated library due to how complicated and prone to change it is.
I'm willing to open a PR (or several) for this, would just want to confirm how they should behave first.