Path: utzoo!utgpu!water!watmath!clyde!rutgers!columbia!westend!dupuy From: dupuy@westend.columbia.edu (Alexander Dupuy) Newsgroups: comp.bugs.4bsd Subject: Re: ctime(3) and leap seconds :-) Keywords: ctime, leap second, epoch Message-ID: <5217@columbia.edu> Date: 15 Jan 88 22:22:53 GMT References: <604@PT.CS.CMU.EDU> <6976@brl-smoke.ARPA> <6977@brl-smoke.ARPA> <7562@elsie.UUCP> Sender: nobody@columbia.edu Reply-To: dupuy@westend.columbia.edu (Alexander Dupuy) Followup-To: comp.bugs.4bsd Organization: Columbia University Computer Science Dept. Lines: 119 In article <7562@elsie.UUCP> ado@elsie.UUCP (Arthur David Olson) writes: >Of course if you're willing to fudge and simply repeat the > 23:59:59 >or the > 00:00:00 >there's no problem. (For those using the mod.sources table-based time >functions, lines such as > > # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S > Rule US 1988 only - Jan 1 00:00:00 -00:00:01 S > >do the trick by repeating the 23:59:59; change the "AT" filed to "00:00:01" >to repeat the first second of the new year rather than the last of the old.) Here's a revision of the tzone/etcetera zoneinfo source file which corrects for leap seconds in UTC (not GMT though - so the GMT rules are consistent with the standard ctime results). After all, if you are a real clockwatcher, and care about things like leap seconds, you have "TZ=UTC" in your .profile, right? Aside from the problem of ctime not generating 23:59:60, zic also sets the dst flag in the zoneinfo files for any rule with nonzero SAVE, even though (in this case) the time is standard. You can go and clear the flag with a binary editor if you care, or you could hack zic. By setting up the rules as decreasingly positive offsets to GMT, we can make UTC a "standard" time with 0 offset from GMT for all times since the last leap second, which is good enough for most purposes. Note also that you must not have NOSOLAR defined, since this creates 14 different UTC savings times. You can work around this by deleting the first 5 leap second rules, at the expense of inaccuracy for years < 1975. @alex --- arpanet: dupuy@columbia.edu uucp: ...!rutgers!columbia!dupuy #!/bin/sh : This is a shar archive. Extract with sh, not csh. : The rest of this file will extract: : : etcetera : echo x - etcetera sed 's/^X//' > etcetera << '//go.sysin dd *' X# @(#)etcetera 3.2 X X# X# We leave GMT without adjustments for leap seconds, for simplicity X# X X# Zone NAME GMTOFF RULES FORMAT [UNTIL] XZone GMT 0 - GMT X X# X# Names for zones that might exist, just so people can set a timezone X# that's right for their area, even if it doesn't have a name or dst rules X# (half hour zones are too much to bother with -- when someone asks!) X# X XZone GMT-12 -12 - GMT-1200 XZone GMT-11 -11 - GMT-1100 XZone GMT-10 -10 - GMT-1000 XZone GMT-9 -9 - GMT-0900 XZone GMT-8 -8 - GMT-0800 XZone GMT-7 -7 - GMT-0700 XZone GMT-6 -6 - GMT-0600 XZone GMT-5 -5 - GMT-0500 XZone GMT-4 -4 - GMT-0400 XZone GMT-3 -3 - GMT-0300 XZone GMT-2 -2 - GMT-0200 XZone GMT-1 -1 - GMT-0100 XZone GMT+1 1 - GMT+0100 XZone GMT+2 2 - GMT+0200 XZone GMT+3 3 - GMT+0300 XZone GMT+4 4 - GMT+0400 XZone GMT+5 5 - GMT+0500 XZone GMT+6 6 - GMT+0600 XZone GMT+7 7 - GMT+0700 XZone GMT+8 8 - GMT+0800 XZone GMT+9 9 - GMT+0900 XZone GMT+10 10 - GMT+1000 XZone GMT+11 11 - GMT+1100 XZone GMT+12 12 - GMT+1200 XZone GMT+13 13 - GMT+1300 # GMT+12 with DST X XLink GMT Greenwich X X# X# For the dedicated clockwatchers, true UTC with leap second adjustments X# (not that this will not work if NOSOLAR is defined) X# X X# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S XRule Leap min only - Jan 1 00:00:00 00:00:14 - XRule Leap 1972 only - Jul 1 00:00:00 00:00:13 - XRule Leap 1973 only - Jan 1 00:00:00 00:00:12 - XRule Leap 1974 only - Jan 1 00:00:00 00:00:11 - XRule Leap 1975 only - Jan 1 00:00:00 00:00:10 - XRule Leap 1976 only - Jan 1 00:00:00 00:00:19 - XRule Leap 1977 only - Jan 1 00:00:00 00:00:08 - XRule Leap 1978 only - Jan 1 00:00:00 00:00:07 - XRule Leap 1979 only - Jan 1 00:00:00 00:00:06 - XRule Leap 1980 only - Jan 1 00:00:00 00:00:05 - XRule Leap 1981 only - Jul 1 00:00:00 00:00:04 - XRule Leap 1982 only - Jul 1 00:00:00 00:00:03 - XRule Leap 1983 only - Jul 1 00:00:00 00:00:02 - XRule Leap 1985 only - Jul 1 00:00:00 00:00:01 - XRule Leap 1988 only - Jan 1 00:00:00 00:00:00 - X X# Zone NAME GMTOFF RULES FORMAT [UNTIL] XZone UTC 0 Leap UTC X XLink UTC UCT XLink UTC Universal //go.sysin dd * exit --- arpanet: dupuy@columbia.edu uucp: ...!rutgers!columbia!dupuy