leap seconds and Linux/Unix, timezones, and zdump

From: Neal McBurnett <neal_at_BCN.BOULDER.CO.US>
Date: Sat, 31 Dec 2005 13:57:49 -0700 (MST)

Here are some notes on facilities in some Unix systems to show
evidence of leap seconds. Some recent distributions are out of date
as noted below. Can folks check others (Solaris, *BSD, etc?).


First, this should work for everyone who cares about time and runs
ntp. Make sure you're in NTP sync with a host that knows a leap
second is coming. Look for "leap=01" in the output of this:

 $ ntpq -c rv
 assID=0 status=46f4 leap_add_sec, sync_ntp, 15 events, event_peer/strat_chg,
 version="ntpd 4.2.0a_at_1:4.2.0a-11-r Mon Mar 14 12:39:28 GMT 2005 (1)"?,
 processor="i686", system="Linux/2.6.10-6-386", leap=01, stratum=3,
 precision=-19, rootdelay=158.366, rootdispersion=77.103, peer=17708,
 refid=82.211.81.145,
 reftime=c76127cd.19f9acff Sat, Dec 31 2005 8:52:45.101, poll=7,
 clock=0xc7612b1b.74322291, state=4, offset=-0.430, frequency=37.132,
 error=0.572, jitter=1.795, stability=64.092


Next check to see if your time zone files are up-to-date. I'm no
expert (help!) but it appears that on many Unix systems, the "Olson"
notion of "right/" timezones allows the system to understand leap
seconds.

E.g. note the back-to-back output of two date commands, with and
without the "right/" timezone prefix:

 $ date; TZ=right/US/Mountain date;
 Sat Dec 31 09:56:22 MST 2005
 Sat Dec 31 09:56:00 MST 2005

That prefix tells the date
command that the system clock includes all seconds (including leap
seconds) since the unix epoch in 1970. Since that is not true
on my machine, it is off by the 22 leap seconds since then.

But will it know about the 23rd one tomorrow? That depends on
up-to-date timezone files.

The zdump command shows time discontinuities (daylight savings, leap
seconds, and legal changes) for the files installed somewhere like
/usr/share/zoneinfo. E.g. here is an excerpt of its output on my
Ubuntu 5.10 (Breezy) system:

 $ zdump -v right/UTC
 ...
 right/UTC Thu Dec 31 23:59:60 1998 UTC = Thu Dec 31 23:59:60 1998 UTC isdst=0 gmtoff=0
 right/UTC Fri Jan 1 00:00:00 1999 UTC = Fri Jan 1 00:00:00 1999 UTC isdst=0 gmtoff=0

Note the famous 23:59:60 entry for the last leap second. But note
that it dosen't now about the 2005 leap second, despite the fact that
my release of Ubuntu came out in October of 2005. The Debian
releases, including unstable, don't seem to be updated either. But
Redhat's Fedora core 4 is up-to-date, as are RHEL and centos.

zdump works for other time zones also, including daylight savings
times changes:

 $ zdump -v right/US/Mountain | grep 1998
  right/US/Mountain Sun Apr 5 08:59:59 1998 UTC = Sun Apr 5 01:59:59 1998 MST isdst=0 gmtoff=-25200
  right/US/Mountain Sun Apr 5 09:00:00 1998 UTC = Sun Apr 5 03:00:00 1998 MDT isdst=1 gmtoff=-21600
  right/US/Mountain Sun Oct 25 07:59:59 1998 UTC = Sun Oct 25 01:59:59 1998 MDT isdst=1 gmtoff=-21600
  right/US/Mountain Sun Oct 25 08:00:00 1998 UTC = Sun Oct 25 01:00:00 1998 MST isdst=0 gmtoff=-25200
  right/US/Mountain Thu Dec 31 23:59:60 1998 UTC = Thu Dec 31 16:59:60 1998 MST isdst=0 gmtoff=-25200
  right/US/Mountain Fri Jan 1 00:00:00 1999 UTC = Thu Dec 31 17:00:00 1998 MST isdst=0 gmtoff=-25200

 $ zdump -v right/US/Mountain | grep 2005

  right/US/Mountain Sun Oct 30 07:59:59 2005 UTC = Sun Oct 30 01:59:59 2005 MDT isdst=1 gmtoff=-21600
  right/US/Mountain Sun Oct 30 08:00:00 2005 UTC = Sun Oct 30 01:00:00 2005 MST isdst=0 gmtoff=-25200

You can get updated time zone tables as indicated at
 http://www.twinsun.com/tz/tz-link.htm

It also includes changes for US daylight savings in 2007.
The package that needs updating for Debian and Ubuntu is "libc6"

Neal McBurnett http://bcn.boulder.co.us/~neal/
Signed and/or sealed mail encouraged. GPG/PGP Keyid: 2C9EBA60
Received on Sat Dec 31 2005 - 12:58:48 PST

This archive was generated by hypermail 2.3.0 : Sat Sep 04 2010 - 09:44:54 PDT