[time-nuts] Leap Quirks

M. Warner Losh imp at bsdimp.com
Sat Jan 3 14:01:43 EST 2009


In message: <m3vdswqmb5.fsf at lugabout.jhcloos.org>
            James Cloos <cloos at jhcloos.com> writes:
: >>>>> "Warner" == M Warner Losh <imp at bsdimp.com> writes:
: 
: Warner> That doesn't match POSIX's mandated behavior...  time_t % 86400 == 0
: Warner> at midnight is an invariant that's violated by the above sequence.  
: 
: By which sequence?

The sequence where midnight % 86400 isn't 0.

: At every point in time where time_t % 86400 == 0 is true gmtime(2), when
: using no zoneinfo file or when using a posix zoneinfo file, will return
: a struct tm where the time of day is 00:00:00.
: 
: (time_t)1230768024 was 2009-01-01 00:00:00 right/UTC
: (time_t)1230768000 was 2009-01-01 00:00:00 posix/UTC
: 
: and the real 2009-01-01 00:00:00 UTC was exacly 1230768024 si seconds
: after 1970-01-01 00:00:00 UTC.

Correct.  The 'right' way here isn't POSIX compliant.  POSIX has no
leap seconds at all.  They don't exist.

: That this leap second was (time_t)1230768023 is is a simple fact of how
: long it has been since the start of 1970.
: 
: That POSIX pretends that 2009 UTC started 24 seconds earlier than it
: did is a bug.

It is the standard.  It isn't desirable behavior, but it is what is
mandated by the standard.  You can argue it is a bug, and I might
agree with you, but that won't make it any less the standard.  And
explicitly part of the standard after much arguments in committee.  It
is one of the things horribly broken by POSIX.

Also, you need to run a hacked ntpd, because the ntp time stamps
follow the posix mandate, not the TAI-like second count...

: Anyone who has some requirement to exactly match POSIX as published can
: use the posix zoneinfo files and have time_t % 86400 == 0 as midnight
: “UTC” every day.  Their idea of time will be off, but they get to keep
: their fixed-sized intervals.

The trouble is that there's a lot of code that depends on this
behavior...

: Anyone who wants to track the real UTC can do so using the right
: zoneinfo files.  By doing so they explicitly choose to ignore
: that particular bit of nonsense in POSIX, but that is OK since it
: is their choice.
: 
: Everyone gets to choose which they prefer.

Correct.

Of course, how do programs that run for years get updated leap second
information so they continue to produce the correct times?  I've never
understood how that part of the 'right' files works...

Warner




More information about the time-nuts mailing list