NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: number of seconds since the epoch
Robert Elz <kre%munnari.OZ.AU@localhost> writes:
> Clearly you're looking for a count of seconds including
> leap seconds, right? That's the magic 24 in your message.
> That is you're not interested in the elastic seconds that
> posix defines, for which there are always exactly 86400 in a day.
If you just need now, there is a way that might border on nice.
If you need the past, more work.
NTP stratum ones are expected to carry a current copy of
ftp://time.nist.gov/pub/leap-seconds.list
in the ntp daemon's keysdir, plus the config line
"crypto leap leap-seconds.list".
Setup ntp thusly, and then:
$ ntptime
ntp_gettime() returns code 0 (OK)
ntp_gettime() returns code 0 (OK)
time d0aa2e3d.103254e0 Wed, Dec 8 2010 11:18:05.063, (.063268811),
maximum error 3325 us, estimated error 20 us, TAI offset 34
^^^^^^^^^^^^^
ntp_gettime() is easily called from C and will deliver the current TAI
offset. Subtract ten to arrive at leapseconds since January 1972.
As far as I know, the interface only knows the current TAI offset,
and not the past. leap-seconds.list certainly contains the data, but
you'll have to do the parsing yourself to compute the TAI offset at a
point in time.
Home |
Main Index |
Thread Index |
Old Index