[tz] 400-year-repeat edge cases

Zefram zefram at fysh.org
Wed Oct 12 20:31:57 UTC 2011


For tzfile readers that make use of the 400-year cycle where a rule can't
be expressed in POSIX-TZ form, I'm concerned that going exactly 400 years
beyond the last rule change isn't sufficient.  The year at the start of
that cycle, the year that would otherwise have been the last one mentioned
in the tzfile, might be contaminated by one-shot rules, making it an
invalid example of the cyclical rules.  Also, the transitions included
for the last year of the cycle don't adequately delimit the whole cycle.

I propose to avoid these edge problems by adding an extra two
years of explicit observations when listing 400 years of the future.
One extra year would probably suffice; two certainly does, and allows
for conservative tzfile readers to drop poorly-delimited observations
at the ends.  Think of them as telomeres.  Attached patch implements.

This affects about six of the tzfiles.  (Between five and seven,
depending on which of my previous patches you applied.)  They mostly
get 36 bytes longer.

-zefram
-------------- next part --------------
diff -ur tz2011j.mod2a/zic.c tz2011j.mod3/zic.c
--- tz2011j.mod2a/zic.c	2011-10-12 09:24:53.000000000 +0100
+++ tz2011j.mod3/zic.c	2011-10-12 21:17:27.000000000 +0100
@@ -2084,11 +2084,11 @@
 		ifree(wp);
 	}
 	if (do_extend) {
-		if (min_year >= INT_MIN + YEARSPERREPEAT)
-			min_year -= YEARSPERREPEAT;
+		if (min_year >= INT_MIN + YEARSPERREPEAT + 2)
+			min_year -= YEARSPERREPEAT + 2;
 		else	min_year = INT_MIN;
-		if (max_year <= INT_MAX - YEARSPERREPEAT)
-			max_year += YEARSPERREPEAT;
+		if (max_year <= INT_MAX - YEARSPERREPEAT - 2)
+			max_year += YEARSPERREPEAT + 2;
 		else	max_year = INT_MAX;
 		/*
 		** Regardless of any of the above,
@@ -2098,7 +2098,7 @@
 		*/
 		if (prodstic) {
 			min_year = 1900;
-			max_year = min_year + YEARSPERREPEAT;
+			max_year = min_year + YEARSPERREPEAT + 2;
 		}
 	}
 	/*


More information about the tz mailing list