[LEAPSECS] [time-nuts] Leap Quirks

Magnus Danielson magnus at rubidium.dyndns.org
Mon Jan 5 20:05:36 EST 2009


M. Warner Losh skrev:

> In message: <20090105102452.GJ14473 at fysh.org>

> Zefram <zefram at fysh.org> writes:

> : M. Warner Losh wrote:

> : >So time_t is effectively defined in POSIX to be:

> : >

> : > d * 86400 + min(tod(x), 86399)

> : >

> : >where d is the number of days since 01-01-1970, and tod is the second

> : >since midnight within the day.

> :

> : Actually it's simpler than that. The expression given by POSIX amounts to

> :

> : d * 86400 + tod(x)

> :

> : so a leap second appears identical to the first second of the next day,

> : rather than a repeat of the previous second.

>

> That's what the broken down time translation results in. However, I

> don't think that POSIX specifies the 'proper' value for the leap

> second because leap seconds are explicitly excluded from the spec.

> The reason it maps to the above is due to the normalization rules for

> the '60' part of the broken down time, not because it is a leap second

> and is defined to map there.


Actually, when you read the rationale it become clear that they where
quite aware of how leap seconds does work. It is not fair to say they
totally ignored it. It is more fair to say that the chose a time_t
representation that does not allow leap seconds to be uniquely
represented but rahter maintained the time_t % 86400 == 0 aspect for
midnight as they thought most systems where best served by this
definition. That this definition causes some of us grief is another thing.

A peculiar aspect of the defined mapping is however that POSIX midnight
(time_t % 86400 == 0) occurs twice (two continous seconds) when a leap
second is inserted such that it should trigger midnight 1 second prior
to UTC midnight, 86400 seconds after the previous midnight and 86401
seconds before the next.
There is a little chance that some software could double-trigger on the
midnight event. Duplicating 23:59:59 is safer in this regard.


> : What's actually implemented

> : by particular kernels varies; Linux, for example, does something in

> : between these, jumping backwards (by 1) a few milliseconds after the

> : start of the leap second.

>

> FreeBSD too. Any NTP based kernel does this.


Many kernels implement the NTP interface, more or less straight as given
I beleive.

Cheers,
Magnus


More information about the LEAPSECS mailing list