F-ckin Leap Seconds, how do they work?

Peter Lothberg roll at Stupi.SE
Tue Jul 3 21:49:40 UTC 2012


> > Maybe we should stop wrenching the poor system time back and forth. We
> > no longer add or subtract daylight savings time (or timezones) to the
> > kernel time, why do we do it with leapseconds? We should really move
> > the leapseconds correction into the display routines like DST and
> > timezones already are. I believe the Olson time code already has ifdefs
> > for doing this. I wonder why the system's internal time isn't run that
> > way.
> 
> I cannot tell you how (literally) shocked I was, to learn from John Stull
> (at IBM, the first guy, apparently, to locate the current screwup and 
> create kernel patches for it) that *the kernel gets this so wrong*.
> 
> It's so off that I wasn't sure I was interpreting the situation properly
> until you posted this.
> 
> This pain should have been undergone at least 15 years ago; 235960 is
> a perfectly valid timestamp; ISO8601 says so.


I leave the computer kernels out of this for a second..:-)

We have a timescale that runs at constant speed forward it's named
"TAI", it is based on the definition on the atomic second. 

Some systems like GPS have their own idea of a "base time" and then
they have a way of telling the difference between "their timescale"
and UTC. In the case of GPS, they took the numer of leap seconds
currently in play when the system was launched and keept that.
(as their calendar is 1024 weeks, mosty receivers use the UTC-GPS
ofset to figure out what modulo 1024 weeks we are in).

TAI is atomic time, UTC(k) is what we use for practical timekeeping,
and the problem at hand is that the atomic second runs at constant
speed, but the earth is not. 

Leapseconds can be both positive and negative, but up to now, the
earth has only slowed down, so we have added seconds.

There are applications on the earth that deals with the earth position
in repect to other planets and the sun, so in order to have one
timescale for everyone UTC is compensated for the earth rotation
speed, when the solar time differs from atomic time with more than
0.94 seconds, we compensate by adding or deleting a second the last
minute of the last day of a month, in pratice they have picked
new-years and jun/jul.

You have all heard "GMT", if we don't insert leap seconds as the earth
is slowing down "GMT" will be "PMT" (paris mean time) in some 65000
years. And day and night will be swapped in 12*65000 years.

So in order to avoid having to ask someone gving you a time and date
what timescale he/she refers to refered we have UTC, and as all things
in life it's a compromize. 

--Peter

Ps: fix your broken code, most systems can handle "leap days" by now, every 4
years, except years that ends with 00..




More information about the NANOG mailing list