[LEAPSECS] BBC radio Crowd Science

Warner Losh imp at bsdimp.com
Tue Jan 31 12:33:23 EST 2017


On Tue, Jan 31, 2017 at 7:54 AM, Steve Summit <scs+ls at eskimo.com> wrote:
> Tom Van Baak and Michael Decker wrote:
>>>> 2017-01-01T00:00:36.5 - 36 s = 2016-12-31T23:59:60.5
>>> What kind of arithmetic is that?
>
> I think it ends up being roughly the same kind of arithmetic
> that tells you that the 60th day of the year is March 1.
> Or maybe February 29.

Maybe he's referring to the fact that the offset is 37s, not 36s. The
offset changes AT THE START OF THE LEAP SECOND. To make the math work,
we'd have something like:

2017-01-01T00:00:(36.5-37)
2017-01-01T00:00:-0.5s

at this point, you have to borrow. To borrow, you have to know if the
prior minute had 59, 60 or 61 seconds. This means you have to know the
old offset before the leap second as well as the new offset after. In
our case, we know both, so there's 61s, continuing the long-hand math,
rippling the change in seconds through the "improper" time to reduce
it to a "proper" time.

2017-01-01T00:-1:61+-0.5
2017-01-01T00:-1:60.5
2017-01-01T-1:59:60.5
here to brorrow we have to get the prior day, rather than go through
that irregular radix math, I'll just jump to the end since that's
boring.
2016-12-31T23:59:60:.5

So I think the math in the earlier message was using the wrong offset
for the leap second (which uses the new offsets which is what makes it
a leap second). I hadn't been reading closely, or I'd likely have
inserted a rant about how this mucks up time of day calculations in a
way that's a pita to code up and how when given to junior programmers
they almost always mess it up (4/5 implementations I've been involved
with had errors in this part of the math). I should write a brief
technical note on this math and how to implement it (though I'm sure
others have as well).

A handy chart for when the offset changes:

Positive Leap:

23:59:58 x
23:59:59 x
23:59:60 x+1
00:00:00 x+1

Negative Leap:

23:59:57 x
23:59:58 x
00:00:00 x-1
00:00:01 x-1

Any other scheme leads to math that doesn't make sense.

> [in a later message]
>> I do have problems with your notation. [...] If your first
>> equation was A = B, then you are now saying A - 36 s = B.
>
> Two totally different uses of "=".  One means "at the same
> point in time"; one means "have the same numerical value".
> Sort of like 100 degrees Celsius = 212 degrees Fahrenheit,
> but 100 * 9 / 5 + 32 = 212.

Yes Time 1 UTC = Time 2 TAI. The UTC and the TAI modify their
respective times in some way, and the = means they are the same moment
in time. The UTC or TAI (or GPS) specifiers tell what the epoch is,
and what adjustment history to the timescale there has been.

Warner


More information about the LEAPSECS mailing list