[tz] Leap seconds puzzle

random832 at fastmail.us random832 at fastmail.us
Wed Apr 8 20:55:25 UTC 2015

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

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.)

When people say POSIX ignores leap seconds, it means that time_t is a
multiple of 86400 at midnight UTC, and that there's no way to identify
what the actual UTC time is for a time_t which is taken around a leap
second. It increments 86400 times in 86401 seconds [some systems may
hold the same value for two seconds with or without various tricks done
with fractional second reporting either before or during the multiple of
86400, others may have this hour or day composed of "seconds" that are
longer than an SI second.]

> So why would they give me a time that matches, to the
> second, the POSIX time on my workstation?  Does NTP send POSIX seconds
> since epoch rather than real ones?  

NTP has its own encoding for time values, and its own epoch, and does
not use the POSIX format over the wire. WWV has its own encoding for
time which includes broken-down hour/minute/second fields. www.time.gov,
of course, displays the time in a human-readable format with broken-down
fields (it is, AIUI, capable of displaying 60 in the seconds field).

Everything has been displayed to you as UTC. The only difference is that
POSIX is not capable of representing a UTC time whose seconds value is
60, and defines a linear scale where the difference between each
successive day is exactly 86400.

More information about the tz mailing list