[LEAPSECS] BBC radio Crowd Science

Tom Van Baak tvb at LeapSecond.com
Sun Jan 29 14:52:19 EST 2017


> TAI is the fundamental time scale, with UTC derived from it.  As TAI
> advances, you can calculate UTC by subtracting TAI-UTC from it.  At TAI
> = 34 seconds, TAI-UTC is 35 and the corresponding UTC time is 23:59:59.
> That can be arithmetically correct only if you don't count the leap
> second, so let's not count it.

That sounds dangerous. There's a one-to-one mapping between valid UTC timestamps and valid TAI timestamps. Yes, you need a table to do the mapping, but the mapping is unambiguous (for recent and near future times).


> When the TAI time is 35 seconds, you would think the UTC time would be
> 0 seconds, but because of the leap second it is 23:59:60.  Thus, the
> value of TAI-UTC doesn't tell you everything you need to know to
> convert from TAI to UTC: you also have to know that there is a leap
> second in progress.

Huh? No, that doesn't sound right at all.

If your TAI-UTC table and code are correct, then every valid UTC timestamp has a TAI equivalent and vice versa. What is *invalid* is a 23:59:59 UTC timestamp (negative leap) or a 23:59:60 UTC timestamp (positive leap) that is not prescribed by the table.

A conversion from UTC to TAI will catch these errors and a conversion from TAI to UTC will not generate these errors. Also, any timestamp with hours<0 or hours>=24 or minutes<0 or minutes>=60 is invalid, without even looking at the table.

For this, it's best not to think of "a leap second" as in progress or as a duration; otherwise you may give preferential treatment to positive leap seconds only, or make special cases for one over the other. Instead think of a leap second as an *event* that forces a table lookup of how long that day is.


> I had thought that TAI-UTC was the only information needed to convert
> from TAI to UTC, and therefore that it could not be a step function
> because of positive leap seconds.  I see now that I was mistaken.  Is
> my new belief correct that you need both TAI-UTC and the knowledge that
> a leap second is in progress to convert from TAI to UTC?

Hmm, it sounds like your new belief is wrong too. That's why I suggested writing tests for your library; so you could catch these errors yourself. The table is all you need to decide how to convert between TAI/UTC and UTC/TAI. Yes, the code gets tricky near +/- N seconds of midnight, where N is |TAI-UTC|.

/tvb


More information about the LEAPSECS mailing list