[tz] JavaScript IANA date/time library, now with support for leap seconds, TAI, TDT

Tony Finch dot at dotat.at
Mon Apr 26 16:17:13 UTC 2021


Kerry Shetline <kerry at shetline.com> wrote:
>
> I’ve just finished up adding a feature I’ve always wanted to have in a
> date/time package, and that’s the ability to properly handle and
> represent leap seconds. Along with that comes conversion to and from TAI
> (International Atomic Time) and astronomical time systems.

I'm flattered that you thought my suggestion for proleptic UTC was worth
implementing, but I'm not sure it's a very good idea - at least it has
significant caveats.

My aim back then was to sketch what might be a reasonable way to bridge
between pre-atomic time and UTC, for code that can only support an integer
offset between UTC and TAI. If your code supports rubber seconds then it
should probably use the USNO table that records the rate and phase offsets
between 1962 and 1972. (I don't know another source of that table, nor
where you can get a copy while maia.usno.navy.mil is down.)

For times in the future, beyond the expiry time of the leap seconds table,
I think an API should refuse to return an answer. It's a category error to
support future conversions between TAI and UTC or POSIX time for a couple
of reasons:

  * TAI is a retrospective timescale; it isn't defined in the future.

  * There is a fixed, defined relationship between POSIX time and future
    calendar dates and times, but that isn't true for TAI.

  * Both these things are also true for UTC, with the added complication
    that UTC can't be represented as a linear count of seconds.

Even if you support rubber seconds, there's a gap between 1958 and 1962,
which you can either fudge or return an error as for times in the future.
If you don't support rubber seconds then it's most sensible to return an
error for any time before 1972.

In general I'm not enthusiastic about the idea of using "TAI" in computer
systems to avoid the complications of UTC, mainly because most computers
don't have access to anything like TAI, so you end up with a fudge that
still has the problems of UTC but papered over with a leaky abstraction
that tries and fails to hide the truth.

Tony.
-- 
f.anthony.n.finch  <dot at dotat.at>  https://dotat.at/
South Biscay, South Fitzroy: Cyclonic mainly northeasterly 3 to 5,
increasing 6 at times. Slight or moderate in south Biscay, moderate or
rough in south Fitzroy. Thundery showers. Good, occasionally poor.


More information about the tz mailing list