Module Name:    src
Committed By:   christos
Date:           Wed May 28 19:13:27 UTC 2014

Modified Files:
        src/lib/libc/time: Makefile NEWS tz-link.htm zic.8 zic.c

Log Message:
welcome to 2014d; zic big bang fixes:
        some programs did not handle large negative time_t values well (gnome)


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/time/Makefile
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/time/NEWS
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/time/tz-link.htm
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/time/zic.8
cvs rdiff -u -r1.45 -r1.46 src/lib/libc/time/zic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/time/Makefile
diff -u src/lib/libc/time/Makefile:1.18 src/lib/libc/time/Makefile:1.19
--- src/lib/libc/time/Makefile:1.18	Tue May 13 12:33:56 2014
+++ src/lib/libc/time/Makefile	Wed May 28 15:13:27 2014
@@ -6,7 +6,7 @@
 PACKAGE=	tzcode
 
 # Version numbers of the code and data distributions.
-VERSION=	2014c
+VERSION=	2014d
 
 # Email address for bug reports.
 BUGEMAIL=	[email protected]
@@ -100,6 +100,7 @@ YEARISTYPE=	./yearistype
 LDLIBS=
 
 # Add the following to the end of the "CFLAGS=" line as needed.
+#  -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
 #  -DHAVE_ADJTIME=0 if `adjtime' does not exist (SVR0?)
 #  -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS)
 #  -DHAVE_GETTEXT=1 if `gettext' works (GNU, Linux, Solaris); also see LDLIBS

Index: src/lib/libc/time/NEWS
diff -u src/lib/libc/time/NEWS:1.2 src/lib/libc/time/NEWS:1.3
--- src/lib/libc/time/NEWS:1.2	Tue May 13 12:33:56 2014
+++ src/lib/libc/time/NEWS	Wed May 28 15:13:27 2014
@@ -1,11 +1,27 @@
 News for the tz database
 
 
+Release 2014d - 2014-05-27 21:34:40 -0700
+
+  Changes affecting code
+
+    zic no longer generates files containing time stamps before the Big Bang.
+    This works around GNOME bug 730332
+    <https://bugzilla.gnome.org/show_bug.cgi?id=730332>.
+    (Thanks to Leonardo Chiquitto for reporting the bug, and to
+    Arthur David Olson and James Cloos for suggesting improvements to the fix.)
+
+  Changes affecting documentation
+
+    tz-link.htm now mentions GNOME.
+
+
 Release 2014c - 2014-05-13 07:44:13 -0700
 
   Changes affecting near-future time stamps
 
-    Egypt observes DST starting May 15.  (Thanks to Ahmad El-Dardiry.)
+    Egypt observes DST starting 2014-05-15 at 24:00.
+    (Thanks to Ahmad El-Dardiry and Gunther Vermier.)
     Details have not been announced, except that DST will not be observed
     during Ramadan.  Guess that DST will stop during the same Ramadan dates as
     Morocco, and that Egypt's future spring and fall transitions will be the

Index: src/lib/libc/time/tz-link.htm
diff -u src/lib/libc/time/tz-link.htm:1.14 src/lib/libc/time/tz-link.htm:1.15
--- src/lib/libc/time/tz-link.htm:1.14	Tue May 13 12:33:56 2014
+++ src/lib/libc/time/tz-link.htm	Wed May 28 15:13:27 2014
@@ -8,7 +8,7 @@
 <meta http-equiv="Content-type" content='text/html; charset="US-ASCII"'>
 <meta name="DC.Creator" content="Eggert, Paul">
 <meta name="DC.Contributor" content="Olson, Arthur David">
-<meta name="DC.Date" content="2014-03-10">
+<meta name="DC.Date" content="2014-05-27">
 <meta name="DC.Description"
  content="Sources of information about time zones and daylight saving time">
 <meta name="DC.Identifier"
@@ -315,6 +315,10 @@ This library is freely available under t
 <abbr>GNU</abbr> Lesser General Public License
 (<abbr title="Lesser General Public License">LGPL</abbr>)</a>,
 and is widely used in <abbr>GNU</abbr>/Linux systems.</li>
+<li><a href="http://www.gnome.org/";>GNOME</a>'s Glib has
+a <code><abbr>tz</abbr></code> binary file reader written in C that
+creates a <code>GTimeZone</code> object representing sets of UTC offsets.
+It is freely available under the <abbr>LGPL</abbr>.</li>
 <li><a href="http://bmsi.com/java/#TZ";>ZoneInfo.java</a>
 is a <code><abbr>tz</abbr></code> binary file reader written in Java.
 It is freely available under the <abbr>LGPL</abbr>.</li>

Index: src/lib/libc/time/zic.8
diff -u src/lib/libc/time/zic.8:1.21 src/lib/libc/time/zic.8:1.22
--- src/lib/libc/time/zic.8:1.21	Fri Sep 20 15:06:54 2013
+++ src/lib/libc/time/zic.8	Wed May 28 15:13:27 2014
@@ -1,5 +1,5 @@
-.\"	$NetBSD: zic.8,v 1.21 2013/09/20 19:06:54 christos Exp $
-.Dd September 20, 2013
+.\"	$NetBSD: zic.8,v 1.22 2014/05/28 19:13:27 christos Exp $
+.Dd May 28, 2014
 .Dt ZIC 8
 .Os
 .Sh NAME
@@ -438,6 +438,11 @@ produces a single transition to daylight
 To get separate transitions
 use multiple zone continuation lines
 specifying transition instants using universal time.
+.Pp
+Time stamps well before the Big Bang are silently omitted from the output.
+This works around bugs in software that mishandles large negative time stamps.
+Call it sour grapes, but pre-Big-Bang time stamps are physically suspect anyway.
+The pre-Big-Bang cutoff time is approximate and may change in future versions.
 .Sh FILES
 .Pa /usr/share/zoneinfo
 - standard directory used for created files

Index: src/lib/libc/time/zic.c
diff -u src/lib/libc/time/zic.c:1.45 src/lib/libc/time/zic.c:1.46
--- src/lib/libc/time/zic.c:1.45	Tue May 13 12:33:56 2014
+++ src/lib/libc/time/zic.c	Wed May 28 15:13:27 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: zic.c,v 1.45 2014/05/13 16:33:56 christos Exp $	*/
+/*	$NetBSD: zic.c,v 1.46 2014/05/28 19:13:27 christos Exp $	*/
 /*
 ** This file is in the public domain, so clarified as of
 ** 2006-07-17 by Arthur David Olson.
@@ -10,7 +10,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: zic.c,v 1.45 2014/05/13 16:33:56 christos Exp $");
+__RCSID("$NetBSD: zic.c,v 1.46 2014/05/28 19:13:27 christos Exp $");
 #endif /* !defined lint */
 
 #include "version.h"
@@ -737,6 +737,36 @@ warning(_("hard link failed, symbolic li
 static const zic_t min_time = (zic_t) -1 << (TIME_T_BITS_IN_FILE - 1);
 static const zic_t max_time = -1 - ((zic_t) -1 << (TIME_T_BITS_IN_FILE - 1));
 
+/* Estimated time of the Big Bang, in seconds since the POSIX epoch.
+   rounded downward to the negation of a power of two that is
+   comfortably outside the error bounds.
+
+   zic does not output time stamps before this, partly because they
+   are physically suspect, and partly because GNOME mishandles them; see
+   GNOME bug 730332 <https://bugzilla.gnome.org/show_bug.cgi?id=730332>.
+
+   For the time of the Big Bang, see:
+
+   Ade PAR, Aghanim N, Armitage-Caplan C et al.  Planck 2013 results.
+   I. Overview of products and scientific results.
+   arXiv:1303.5062 2013-03-20 20:10:01 UTC
+   <http://arxiv.org/pdf/1303.5062v1> [PDF]
+
+   Page 36, Table 9, row Age/Gyr, column Planck+WP+highL+BAO 68% limits
+   gives the value 13.798 plus-or-minus 0.037 billion years.
+   Multiplying this by 1000000000 and then by 31557600 (the number of
+   seconds in an astronomical year) gives a value that is comfortably
+   less than 2**59, so BIG_BANG is - 2**59.
+
+   BIG_BANG is approximate, and may change in future versions.
+   Please do not rely on its exact value.  */
+
+#ifndef BIG_BANG
+#define BIG_BANG (- (1LL << 59))
+#endif
+
+static const zic_t big_bang_time = BIG_BANG;
+
 static int
 itsdir(const char *const name)
 {
@@ -1188,10 +1218,6 @@ inleap(char **const fields, const int nf
 			return;
 	}
 	dayoff = oadd(dayoff, day - 1);
-	if (dayoff < 0 && !TYPE_SIGNED(zic_t)) {
-		error(_("time before zero"));
-		return;
-	}
 	if (dayoff < min_time / SECSPERDAY) {
 		error(_("time too small"));
 		return;
@@ -1200,7 +1226,7 @@ inleap(char **const fields, const int nf
 		error(_("time too large"));
 		return;
 	}
-	t = (zic_t) dayoff * SECSPERDAY;
+	t = dayoff * SECSPERDAY;
 	tod = gethms(fields[LP_TIME], _("invalid time of day"), FALSE);
 	cp = fields[LP_CORR];
 	{
@@ -1229,7 +1255,12 @@ inleap(char **const fields, const int nf
 				));
 			return;
 		}
-		leapadd(tadd(t, tod), positive, lp->l_value, count);
+		t = tadd(t, tod);
+		if (t < big_bang_time) {
+			error(_("leap second precedes Big Bang"));
+			return;
+		}
+		leapadd(t, positive, lp->l_value, count);
 	}
 }
 
@@ -1489,7 +1520,7 @@ writezone(const char *const name, const 
 
 		toi = 0;
 		fromi = 0;
-		while (fromi < timecnt && attypes[fromi].at < min_time)
+		while (fromi < timecnt && attypes[fromi].at < big_bang_time)
 			++fromi;
 		for ( ; fromi < timecnt; ++fromi) {
 			if (toi > 1 && ((attypes[fromi].at +
@@ -2184,9 +2215,9 @@ outzone(const struct zone *const zpfirst
 		*/
 		stdoff = 0;
 		zp = &zpfirst[i];
-		usestart = i > 0 && (zp - 1)->z_untiltime > min_time;
+		usestart = i > 0 && (zp - 1)->z_untiltime > big_bang_time;
 		useuntil = i < (zonecount - 1);
-		if (useuntil && zp->z_untiltime <= min_time)
+		if (useuntil && zp->z_untiltime <= big_bang_time)
 			continue;
 		gmtoff = zp->z_gmtoff;
 		eat(zp->z_filename, zp->z_linenum);
@@ -2202,7 +2233,7 @@ outzone(const struct zone *const zpfirst
 			if (usestart) {
 				addtt(starttime, type);
 				usestart = FALSE;
-			} else	addtt(min_time, type);
+			} else	addtt(big_bang_time, type);
 		} else for (year = min_year; year <= max_year; ++year) {
 			if (useuntil && year > zp->z_untilrule.r_hiyear)
 				break;
@@ -2383,8 +2414,8 @@ error(_("can't determine time zone abbre
 static void
 addtt(const zic_t starttime, int type)
 {
-	if (starttime <= min_time ||
-		(timecnt == 1 && attypes[0].at < min_time)) {
+	if (starttime <= big_bang_time ||
+		(timecnt == 1 && attypes[0].at < big_bang_time)) {
 		gmtoffs[0] = gmtoffs[type];
 		isdsts[0] = isdsts[type];
 		ttisstds[0] = ttisstds[type];

Reply via email to