[tz] Leap seconds puzzle

Paul_Koning at dell.com Paul_Koning at dell.com
Wed Apr 8 23:52:17 UTC 2015

> On Apr 8, 2015, at 4:55 PM, <random832 at fastmail.us> <random832 at fastmail.us> wrote:
> On Wed, Apr 8, 2015, at 15:02, Paul_Koning at dell.com wrote:
>> The Theory file says that POSIX requires leap seconds to be ignored.  And
>> indeed, if I set my system timezone to a POSIX zone description and ask
>> it to convert a time value that’s an integer multiple of 86400, I end up
>> at an exact hour (or half hour) multiple, for example exactly midnight if
>> UTC.  And similarly, if I set my zone to a “right” one and do the
>> conversion, I get a time that’s a few seconds shy of the exact multiple,
>> as expected.
>> I can also see that my default timezone definitions on my various Unix
>> machines are POSIX ones, again as expected.
>> So here is the puzzle.  I would expect WWV, and www.time.gov, to reflect
>> leap seconds.
> What exactly do you think is meant by "reflect" or "ignore" leap
> seconds?
> 2015-04-08 00:00:00 UTC is the same real moment in time whether you use
> leap seconds or not. The only difference is in what the integer value of
> time_t corresponding to that moment is (1428451200 or 1428451225). There
> isn't a separate "no leap second" calendar that stays some number of
> seconds behind (well, there are in fact several, notably TAI and GPS,
> but there's no reason to expect WWV or time.gov to use these to report
> time, nor should anything about POSIX "ignoring leap seconds" be
> construed to mean POSIX systems use such a system.)

Yes, my question was quite a muddle.  Fortunately, Dr. Allen decrypted it well enough to send me the information I was looking for.  Now that I know the answer, I can restate the question so it actually makes sense.

I have a Unix system that keeps time internally by time_t, POSIX style, i.e., time is seconds since the epoch not counting leap seconds.  And the NTP protocol encodes time as seconds since an epoch (a different one).

My Unix box is synchronized by NTP.  So how does it manage to keep the exact UTC time that references such as WWV show, even though as a POSIX system it doesn’t count leap seconds?

The unstated assumption here is that NTP encodes time as elapsed seconds from its epoch including leap seconds.  And while RFC 5905 is not explicit, it has enough hints to make you believe this is the case.

But in fact that is not so; NTP, at least as used in practice, encodes time as seconds from its epoch NOT counting leap seconds.  So, in essence, it sends the POSIX time_t value plus 2,208,988,800 (since it starts in 1900 not 1970).  And that is why my workstation clock is correct.


More information about the tz mailing list