[ntp:questions] POSIX leap seconds versus the current NTP behaviour

Dennis Ferguson dennis.c.ferguson at gmail.com
Wed May 4 03:19:41 UTC 2011


Hello,

A strict reading of the part of the POSIX standard defining "seconds
since the epoch" would seem to require that when a leap second is added the
clock should be stepped back at 00:00:01.  That is, the second which should
be replayed is the second whose "seconds since the epoch" representation is
an even multiple of 86400.  Right now the NTP implementation doesn't do that,
it instead steps the clock back at 00:00:00 and replays the second which is
one before the even multiple of 86400 in the "seconds since the epoch"
representation, to match what seems to be required for the NTP timescale.

For a new implementation of this is there any reason not to do the kernel
timekeeping the way POSIX seems to want it?  I thought I preferred the NTP
handling since it seemed to keep the leap problem on the correct day (for
an "all days have 86400 seconds" timescale, which describes both the NTP and
the POSIX timescales), but I've since decided that might not be all that
important and I appreciate the symmetry of the POSIX approach (leaps forward
occur at 23:59:59, leaps back at 00:00:01, and both leaps end up at 00:00:00)
as well as the fact that the POSIX approach yields a simple equation to determine
the conversion from time-of-day to seconds-since-the-epoch which is always
valid, even across a leap (and even if the inverse conversion is ambiguous)
while I'm having difficulty finding a similar description of NTP's behaviour.

Dennis Ferguson


More information about the questions mailing list