Quoth "Peter J. Holzer said:
When doing calendar calculations which may possibly include future dates
you cannot use leap seconds. Leap seconds are determined by observation
every six months, so at this point of time it is impossible to know how
many seconds the year 2008 will have.
This is why POSIX timestamps don't use leap seconds. The POSIX timestamp
1199145600 always refers to 2008-01-01 00:00:00 UTC and the POSIX
timestamp 1230768000 always refers to 2009-01-01 00:00:00 UTC,
regardless of the number of actual seconds between these dates.
OK, now I'm fascinated... what happens when a leap second occurs?
time(3) returns the same value for two seconds in a row? That sounds...
confusing, although I suppose it's similar to what adjtime(2) does...
[Spurious Perl connection: this is similar to the hobbit's system of
treating leap days as not part of the year...
]
What does the hobbit's system have to do with Perl?
Anyway, to answer the question, there are a number of ways of dealing
with leap seconds and it depends on the system which one is used:
1) Just ignore the problem. At some time after the leap second, the
system's time synchronisation system (probably NTP) will notice that
the clock is now one second fast (or slow) and adjust accordingly.
Different systems in your network will probably notice this at
different times and the PLL may overshoot, so for a few hours the
clocks of the systems may differ by a second or more until they have
all converged again. However, you have similar problems after a
reboot and reboots probably occur more often than leap seconds.
2) Step the clock backwards or forwards by 1 second. Stepping the clock
backwards may cause problems for some programs which assume
monotonically increasing time. But again, time steps often occur
after a reboot, so that may be acceptable.
3) Halt the clock instead of stepping backwards: For one second, all
calls to gettimeofday either return the same value, or just increment
the microsecond counter.
I am not sure, but I think Linux uses the third method. Don't know about
other systems.
hp