*** /tmp/,aaustralasia 2013-05-23 19:44:48.910652000 +0300 --- /tmp/,baustralasia 2013-05-23 19:44:49.097852300 +0300 *************** *** 230,239 **** # - Macquarie Island will stay on UTC+11 for winter and therefore not # switch back from daylight savings time when other parts of Australia do # on 4 April. Zone Antarctica/Macquarie 0 - zzz 1899 Nov 10:00 - EST 1916 Oct 1 2:00 10:00 1:00 EST 1917 Feb ! 10:00 Aus EST 1919 Apr 0 - zzz 1948 Mar 25 10:00 Aus EST 1967 10:00 AT EST 2010 Apr 4 3:00 --- 230,245 ---- # - Macquarie Island will stay on UTC+11 for winter and therefore not # switch back from daylight savings time when other parts of Australia do # on 4 April. + # + # From Arthur David Olson (2013-05-23): + # The 1919 transition is overspecified below so pre-2013 zics + # will produce a binary file with an EST-type as the first 32-bit type; + # this is required for correct handling of times before 1916 by + # pre-2013 versions of localtime. Zone Antarctica/Macquarie 0 - zzz 1899 Nov 10:00 - EST 1916 Oct 1 2:00 10:00 1:00 EST 1917 Feb ! 10:00 Aus EST 1919 Apr 1 0:00s 0 - zzz 1948 Mar 25 10:00 Aus EST 1967 10:00 AT EST 2010 Apr 4 3:00 *** /tmp/,alocaltime.c 2013-05-23 19:44:49.285052600 +0300 --- /tmp/,blocaltime.c 2013-05-23 19:44:49.363052800 +0300 *************** *** 112,117 **** --- 112,118 ---- char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt), (2 * (MY_TZNAME_MAX + 1)))]; struct lsinfo lsis[TZ_MAX_LEAPS]; + int defaulttype; /* for early times or if no transitions */ }; struct rule { *************** *** 582,587 **** --- 583,622 ---- break; } } + /* + ** If type 0 is is unused in transitions, + ** it's the type to use for early times. + */ + for (i = 0; i < sp->typecnt; ++i) + if (sp->types[i] == 0) + break; + i = (i >= sp->typecnt) ? 0 : -1; + /* + ** Absent the above, + ** if there are transition times + ** and the first transition is to a daylight time + ** find the standard type less than and closest to + ** the type of the first transition. + */ + if (i < 0 && sp->timecnt > 0 && sp->ttis[sp->types[0]].tt_isdst) { + i = sp->types[0]; + while (--i >= 0) + if (!sp->ttis[i].tt_isdst) + break; + } + /* + ** If no result yet, find the first standard type. + ** If there is none, punt to type zero. + */ + if (i < 0) { + i = 0; + while (sp->ttis[i].tt_isdst) + if (++i >= sp->typecnt) { + i = 0; + break; + } + } + sp->defaulttype = i; #ifdef ALL_STATE free(up); #endif /* defined ALL_STATE */ *************** *** 1283,1294 **** return result; } if (sp->timecnt == 0 || t < sp->ats[0]) { ! i = 0; ! while (sp->ttis[i].tt_isdst) ! if (++i >= sp->typecnt) { ! i = 0; ! break; ! } } else { register int lo = 1; register int hi = sp->timecnt; --- 1318,1324 ---- return result; } if (sp->timecnt == 0 || t < sp->ats[0]) { ! i = sp->defaulttype; } else { register int lo = 1; register int hi = sp->timecnt; *** /tmp/,azic.c 2013-05-23 19:44:49.550253100 +0300 --- /tmp/,bzic.c 2013-05-23 19:44:49.643853300 +0300 *************** *** 1414,1421 **** fromi = 0; while (fromi < timecnt && attypes[fromi].at < min_time) ++fromi; ! if (isdsts[0] == 0) ! while (fromi < timecnt && attypes[fromi].type == 0) ++fromi; /* handled by default rule */ for ( ; fromi < timecnt; ++fromi) { if (toi != 0 && ((attypes[fromi].at + --- 1414,1424 ---- fromi = 0; while (fromi < timecnt && attypes[fromi].at < min_time) ++fromi; ! /* ! ** Remember that type 0 is reserved. ! */ ! if (isdsts[1] == 0) ! while (fromi < timecnt && attypes[fromi].type == 1) ++fromi; /* handled by default rule */ for ( ; fromi < timecnt; ++fromi) { if (toi != 0 && ((attypes[fromi].at + *************** *** 1517,1523 **** } thistimelim = thistimei + thistimecnt; thisleaplim = thisleapi + thisleapcnt; ! for (i = 0; i < typecnt; ++i) writetype[i] = thistimecnt == timecnt; if (thistimecnt == 0) { /* --- 1520,1530 ---- } thistimelim = thistimei + thistimecnt; thisleaplim = thisleapi + thisleapcnt; ! /* ! ** Remember that type 0 is reserved. ! */ ! writetype[0] = FALSE; ! for (i = 1; i < typecnt; ++i) writetype[i] = thistimecnt == timecnt; if (thistimecnt == 0) { /* *************** *** 1533,1540 **** /* ** For America/Godthab and Antarctica/Palmer */ if (thistimei == 0) ! writetype[0] = TRUE; } #ifndef LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH /* --- 1540,1550 ---- /* ** For America/Godthab and Antarctica/Palmer */ + /* + ** Remember that type 0 is reserved. + */ if (thistimei == 0) ! writetype[1] = TRUE; } #ifndef LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH /* *************** *** 1584,1591 **** } #endif /* !defined LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH */ thistypecnt = 0; for (i = 0; i < typecnt; ++i) ! typemap[i] = writetype[i] ? thistypecnt++ : -1; for (i = 0; i < sizeof indmap / sizeof indmap[0]; ++i) indmap[i] = -1; thischarcnt = 0; --- 1594,1619 ---- } #endif /* !defined LEAVE_SOME_PRE_2011_SYSTEMS_IN_THE_LURCH */ thistypecnt = 0; + /* + ** Potentially, set type 0 to that of lowest-valued time. + */ + if (thistimei > 0) { + for (i = 1; i < typecnt; ++i) + if (writetype[i] && !isdsts[i]) + break; + if (i != types[thistimei - 1]) { + i = types[thistimei - 1]; + gmtoffs[0] = gmtoffs[i]; + isdsts[0] = isdsts[i]; + ttisstds[0] = ttisstds[i]; + ttisgmts[0] = ttisgmts[i]; + abbrinds[0] = abbrinds[i]; + writetype[0] = TRUE; + writetype[i] = FALSE; + } + } for (i = 0; i < typecnt; ++i) ! typemap[i] = writetype[i] ? thistypecnt++ : 0; for (i = 0; i < sizeof indmap / sizeof indmap[0]; ++i) indmap[i] = -1; thischarcnt = 0; *************** *** 1942,1947 **** --- 1970,1980 ---- updateminmax(leapminyear); updateminmax(leapmaxyear + (leapmaxyear < INT_MAX)); } + /* + ** Reserve type 0. + */ + gmtoffs[0] = isdsts[0] = ttisstds[0] = ttisgmts[0] = abbrinds[0] = -1; + typecnt = 1; for (i = 0; i < zonecount; ++i) { zp = &zpfirst[i]; if (i < zonecount - 1)