[LEAPSECS] leapseconds, converting between GPS time (week, second) and UTC

Gary E. Miller gem at rellim.com
Wed Jan 16 00:09:18 EST 2019


Yo Warner!

On Tue, 15 Jan 2019 17:45:32 -0700
Warner Losh <imp at bsdimp.com> wrote:

> > > Except that's not a leap second. struct tm doesn't do leap seconds
> > > really. It kinda sorta does, but it kinda sorts doesn't.  
> >
> > Well, it does in a modern Linux kernel.  Otherwise NTPD would fail
> > on the leap second, and that only happens every year so.  :-)
> >  
> 
> You are wrong. The kernel doesn't use struct tm.

I never said the kernel uses struct tm.  I said you can query the kernel for
the time in a struct tm.

> The kernel does this
> by ticking either in TAI or by incrementing a TAI offset. ntpd uses a
> different interface that exposes these things to it so it can
> broadcast the leap second indicators correctly.

Yup.

> > > First, when you convert back and forth to time_t, you lose leap
> > > second information. It's impossible to convert back and forth
> > > from at least the UTC time zone. There's some 'right' time zones,
> > > but they aren't strictly speaking POSIX compliant because it uses
> > > the wrong math. Non-conforming, but damned useful and not wrong.  
> >
> > Which is why you can't use time_t in UTC,  but time_t in TAI
> > can work, as well as struct tm, usually.  Lot's of latent bugs...
> >  
> 
> No. time_t is not TAI or GPS. It is UTC. Adjusted UTC.

No, time_t is just a way to count seconds.  See man difftime() for a 
use of time_t that is unrelated to any particular epoch.

> It is the
> number of SI seconds since 1970, minus all the positive leap seconds,
> plus all the negative ones.

Ciration please?  I already cited the Linux doc that says otherwise.

> > If you squint at it, GPS time (gps weeks, time of week) is just
> > another notation very similar to time.  And we know that works.
> >  
> 
> GPS time has no leap seconds. It's a monotonic count since 1980.

Correct.

> > Since future leap seconds are unknown, and unknowable, there is no
> > possible valid way to do this on the time scale of years.
> >  
> 
> Correct. This is the fundamental flaw of UTC.

Or a flaw of the universe.  For some reason the earth refuses to rotate
uniformly.

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
	gem at rellim.com  Tel:+1 541 382 8588

	    Veritas liberabit vos. -- Quid est veritas?
    "If you can’t measure it, you can’t improve it." - Lord Kelvin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 851 bytes
Desc: OpenPGP digital signature
URL: <https://pairlist6.pair.net/pipermail/leapsecs/attachments/20190115/6a01a1cb/attachment.sig>


More information about the LEAPSECS mailing list