11 comments

[ 3.6 ms ] story [ 8.6 ms ] thread
Thanks for sharing. Date math is my kryptonite.
Pronounced tinsel?
This is an interesting question. If it enjoys some success, I'll come up with a creative pronunciation… ;-) Tinsel is certainly nice!
Just put a line in the README that it’s “pronounced with a hard G, like noon”, then wait to see what the MC at the first conference uses when they introduce you.
What’s the comparison with the well known JS/TS date time libraries such as date-fns or the older moment.js?
The focus is just on converting dates, there's no idea of formatting dates (other than a simple, localized ISO string, which may be useful to some for further parsing). It returns an object with numeric properties, letting you decide on what to do with it and what the actual format should be.

Since it relies on the Intl implementation of the browser (which is supported by all modern browser, but only partly by later versions of MSIE), it's light-weight (ca 1.3 KB minified and gzipped) and should be up to date regarding day light saving time, etc., without any further maintenance required. (On the other hand, as you rely on a user's browser and the OS – as in the demo widget –, it is not recommended for mission critical tasks, like in banking. But this should be rather obvious to those designing such applications.)

Very well done, and useful! Thank you for building this, and releasing it for everyone to use.
Update: Version 1.1 now also supports time zone aliases (both TZIntl and TZProvider). – You should see some more time zones in the demo widget.

(Aliases are now included in any test and there's also an option to include aliases in `TZProvider.enumerate(<boolean: all>)`, which still defaults to unique time zones like `Intl.supportedValuesOf("timeZone")`.)