diff options
author | 2011-04-25 13:27:27 +0000 | |
---|---|---|
committer | 2011-04-25 13:27:27 +0000 | |
commit | c304db871fb492d373a30786c453fca04bb4895a (patch) | |
tree | d6a9105e1a2ad1ff9b19725483748c356ed647c7 /lib/libc | |
parent | Update to tzdata2011g from elsie.nci.nih.gov (diff) | |
download | wireguard-openbsd-c304db871fb492d373a30786c453fca04bb4895a.tar.xz wireguard-openbsd-c304db871fb492d373a30786c453fca04bb4895a.zip |
Update to tzcode2011g from elsie.nci.nih.gov.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/time/Theory | 35 | ||||
-rw-r--r-- | lib/libc/time/localtime.c | 130 | ||||
-rw-r--r-- | lib/libc/time/tz-art.htm | 25 | ||||
-rw-r--r-- | lib/libc/time/tz-link.htm | 17 | ||||
-rw-r--r-- | lib/libc/time/zic.c | 27 |
5 files changed, 165 insertions, 69 deletions
diff --git a/lib/libc/time/Theory b/lib/libc/time/Theory index d40ed4468b1..b8a14f44730 100644 --- a/lib/libc/time/Theory +++ b/lib/libc/time/Theory @@ -1,12 +1,13 @@ -$OpenBSD: Theory,v 1.14 2010/08/23 22:35:34 millert Exp $ -@(#)Theory 8.4 +$OpenBSD: Theory,v 1.15 2011/04/25 13:27:27 millert Exp $ +@(#)Theory 8.6 This file is in the public domain, so clarified as of 2009-05-17 by Arthur David Olson. ----- Outline ----- Time and date functions - Names of time zone regions + Scope of the tz database + Names of time zone rule files Time zone abbreviations Calendrical issues Time and time zones on Mars @@ -193,6 +194,31 @@ more powerful time conversion functions can be standardized, so much the better. +----- Scope of the tz database ----- + +The tz database attempts to record the history and predicted future of +all computer-based clocks that track civil time. To represent this +data, the world is partitioned into regions whose clocks all agree +about time stamps that occur after the somewhat-arbitrary cutoff point +of the POSIX Epoch (1970-01-01 00:00:00 UTC). For each such region, +the database records all known clock transitions, and labels the region +with a notable location. + +Clock transitions before 1970 are recorded for each such location, +because most POSIX-compatible systems support negative time stamps and +could misbehave if data were omitted for pre-1970 transitions. +However, the database is not designed for and does not suffice for +applications requiring accurate handling of all past times everywhere, +as it would take far too much effort and guesswork to record all +details of pre-1970 civil timekeeping. + +As noted in the README file, the tz database is not authoritative +(particularly not for pre-1970 time stamps), and it surely has errors. +Corrections are welcome and encouraged. Users requiring authoritative +data should consult national standards bodies and the references cited +in the database's comments. + + ----- Names of time zone rule files ----- The time zone rule file naming conventions attempt to strike a balance @@ -288,8 +314,7 @@ and these older names are still supported. See the file `backward' for most of these older names (e.g. `US/Eastern' instead of `America/New_York'). The other old-fashioned names still supported are -`WET', `CET', `MET', `EET' (see the file `europe'), -and `Factory' (see the file `factory'). +`WET', `CET', `MET', and `EET' (see the file `europe'). ----- Time zone abbreviations ----- diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index 0ba6a578230..020da1840ba 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: localtime.c,v 1.36 2010/11/30 00:38:58 tedu Exp $ */ +/* $OpenBSD: localtime.c,v 1.37 2011/04/25 13:27:27 millert Exp $ */ /* ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. @@ -335,12 +335,22 @@ register const int doextend; register int fid; register int stored; register int nread; - union { + typedef union { struct tzhead tzhead; char buf[2 * sizeof(struct tzhead) + 2 * sizeof *sp + 4 * TZ_MAX_TIMES]; - } *u; + } u_t; +#ifdef ALL_STATE + register u_t * up; + + up = (u_t *) calloc(1, sizeof *up); + if (up == NULL) + return -1; +#else /* !defined ALL_STATE */ + u_t u; + register u_t * const up = &u; +#endif /* !defined ALL_STATE */ sp->goback = sp->goahead = FALSE; if (name != NULL && issetugid() != 0) @@ -348,7 +358,7 @@ register const int doextend; name[0] == '/' || strchr(name, '.')) name = NULL; if (name == NULL && (name = TZDEFAULT) == NULL) - return -1; + goto oops; { register int doaccess; /* @@ -365,9 +375,9 @@ register const int doextend; doaccess = name[0] == '/'; if (!doaccess) { if ((p = TZDIR) == NULL) - return -1; + goto oops; if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) - return -1; + goto oops; (void) strlcpy(fullname, p, sizeof fullname); (void) strlcat(fullname, "/", sizeof fullname); (void) strlcat(fullname, name, sizeof fullname); @@ -379,37 +389,32 @@ register const int doextend; name = fullname; } if (doaccess && access(name, R_OK) != 0) - return -1; + goto oops; if ((fid = open(name, OPEN_MODE)) == -1) - return -1; + goto oops; } - u = malloc(sizeof(*u)); - if (!u) { - close(fid); - return -1; - } - nread = read(fid, u->buf, sizeof u->buf); + nread = read(fid, up->buf, sizeof up->buf); if (close(fid) < 0 || nread <= 0) - goto bad; + goto oops; for (stored = 4; stored <= 8; stored *= 2) { int ttisstdcnt; int ttisgmtcnt; - ttisstdcnt = (int) detzcode(u->tzhead.tzh_ttisstdcnt); - ttisgmtcnt = (int) detzcode(u->tzhead.tzh_ttisgmtcnt); - sp->leapcnt = (int) detzcode(u->tzhead.tzh_leapcnt); - sp->timecnt = (int) detzcode(u->tzhead.tzh_timecnt); - sp->typecnt = (int) detzcode(u->tzhead.tzh_typecnt); - sp->charcnt = (int) detzcode(u->tzhead.tzh_charcnt); - p = u->tzhead.tzh_charcnt + sizeof u->tzhead.tzh_charcnt; + ttisstdcnt = (int) detzcode(up->tzhead.tzh_ttisstdcnt); + ttisgmtcnt = (int) detzcode(up->tzhead.tzh_ttisgmtcnt); + sp->leapcnt = (int) detzcode(up->tzhead.tzh_leapcnt); + sp->timecnt = (int) detzcode(up->tzhead.tzh_timecnt); + sp->typecnt = (int) detzcode(up->tzhead.tzh_typecnt); + sp->charcnt = (int) detzcode(up->tzhead.tzh_charcnt); + p = up->tzhead.tzh_charcnt + sizeof up->tzhead.tzh_charcnt; if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) - goto bad; - if (nread - (p - u->buf) < + goto oops; + if (nread - (p - up->buf) < sp->timecnt * stored + /* ats */ sp->timecnt + /* types */ sp->typecnt * 6 + /* ttinfos */ @@ -417,7 +422,7 @@ register const int doextend; sp->leapcnt * (stored + 4) + /* lsinfos */ ttisstdcnt + /* ttisstds */ ttisgmtcnt) /* ttisgmts */ - goto bad; + goto oops; for (i = 0; i < sp->timecnt; ++i) { sp->ats[i] = (stored == 4) ? detzcode(p) : detzcode64(p); @@ -426,7 +431,7 @@ register const int doextend; for (i = 0; i < sp->timecnt; ++i) { sp->types[i] = (unsigned char) *p++; if (sp->types[i] >= sp->typecnt) - goto bad; + goto oops; } for (i = 0; i < sp->typecnt; ++i) { register struct ttinfo * ttisp; @@ -436,11 +441,11 @@ register const int doextend; p += 4; ttisp->tt_isdst = (unsigned char) *p++; if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) - goto bad; + goto oops; ttisp->tt_abbrind = (unsigned char) *p++; if (ttisp->tt_abbrind < 0 || ttisp->tt_abbrind > sp->charcnt) - goto bad; + goto oops; } for (i = 0; i < sp->charcnt; ++i) sp->chars[i] = *p++; @@ -465,7 +470,7 @@ register const int doextend; ttisp->tt_ttisstd = *p++; if (ttisp->tt_ttisstd != TRUE && ttisp->tt_ttisstd != FALSE) - goto bad; + goto oops; } } for (i = 0; i < sp->typecnt; ++i) { @@ -478,7 +483,7 @@ register const int doextend; ttisp->tt_ttisgmt = *p++; if (ttisp->tt_ttisgmt != TRUE && ttisp->tt_ttisgmt != FALSE) - goto bad; + goto oops; } } /* @@ -511,11 +516,11 @@ register const int doextend; /* ** If this is an old file, we're done. */ - if (u->tzhead.tzh_version[0] == '\0') + if (up->tzhead.tzh_version[0] == '\0') break; - nread -= p - u->buf; + nread -= p - up->buf; for (i = 0; i < nread; ++i) - u->buf[i] = p[i]; + up->buf[i] = p[i]; /* ** If this is a narrow integer time_t system, we're done. */ @@ -523,13 +528,13 @@ register const int doextend; break; } if (doextend && nread > 2 && - u->buf[0] == '\n' && u->buf[nread - 1] == '\n' && + up->buf[0] == '\n' && up->buf[nread - 1] == '\n' && sp->typecnt + 2 <= TZ_MAX_TYPES) { struct state ts; register int result; - u->buf[nread - 1] = '\0'; - result = tzparse(&u->buf[1], &ts, FALSE); + up->buf[nread - 1] = '\0'; + result = tzparse(&up->buf[1], &ts, FALSE); if (result == 0 && ts.typecnt == 2 && sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) { for (i = 0; i < 2; ++i) @@ -573,10 +578,14 @@ register const int doextend; break; } } - free(u); +#ifdef ALL_STATE + (void) free((void *) up); +#endif /* defined ALL_STATE */ return 0; -bad: - free(u); +oops: +#ifdef ALL_STATE + (void) free((void *) up); +#endif /* defined ALL_STATE */ return -1; } @@ -925,6 +934,7 @@ const int lastditch; register unsigned char * typep; register char * cp; register int load_result; + static struct ttinfo zttinfo; INITIALIZE(dstname); stdname = name; @@ -997,6 +1007,7 @@ const int lastditch; /* ** Two transitions per year, from EPOCH_YEAR forward. */ + sp->ttis[0] = sp->ttis[1] = zttinfo; sp->ttis[0].tt_gmtoff = -dstoffset; sp->ttis[0].tt_isdst = 1; sp->ttis[0].tt_abbrind = stdlen + 1; @@ -1110,8 +1121,8 @@ const int lastditch; } /* ** Finally, fill in ttis. - ** ttisstd and ttisgmt need not be handled. */ + sp->ttis[0] = sp->ttis[1] = zttinfo; sp->ttis[0].tt_gmtoff = -stdoffset; sp->ttis[0].tt_isdst = FALSE; sp->ttis[0].tt_abbrind = 0; @@ -1124,6 +1135,7 @@ const int lastditch; dstlen = 0; sp->typecnt = 1; /* only standard time */ sp->timecnt = 0; + sp->ttis[0] = zttinfo; sp->ttis[0].tt_gmtoff = -stdoffset; sp->ttis[0].tt_isdst = 0; sp->ttis[0].tt_abbrind = 0; @@ -1635,31 +1647,39 @@ char * buf; #endif /* !defined WRONG */ /* -** Simplified normalize logic courtesy Paul Eggert. +** Normalize logic courtesy Paul Eggert. */ static int -increment_overflow(number, delta) -int * number; -int delta; +increment_overflow(ip, j) +int * const ip; +int j; { - int number0; + register int const i = *ip; - number0 = *number; - *number += delta; - return (*number < number0) != (delta < 0); + /* + ** If i >= 0 there can only be overflow if i + j > INT_MAX + ** or if j > INT_MAX - i; given i >= 0, INT_MAX - i cannot overflow. + ** If i < 0 there can only be overflow if i + j < INT_MIN + ** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow. + */ + if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i)) + return TRUE; + *ip += j; + return FALSE; } static int -long_increment_overflow(number, delta) -long * number; -int delta; +long_increment_overflow(lp, m) +long * const lp; +int const m; { - long number0; + register long const l = *lp; - number0 = *number; - *number += delta; - return (*number < number0) != (delta < 0); + if ((l >= 0) ? (m > LONG_MAX - l) : (m < LONG_MIN - l)) + return TRUE; + *lp += m; + return FALSE; } static int diff --git a/lib/libc/time/tz-art.htm b/lib/libc/time/tz-art.htm index ff2afa90624..902371eab5f 100644 --- a/lib/libc/time/tz-art.htm +++ b/lib/libc/time/tz-art.htm @@ -9,7 +9,7 @@ PUBLIC "-//W3C//DTD HTML 4.01//EN" <body> <h1>Time and the Arts</h1> <address> -@(#)tz-art.htm 8.17 +@(#)tz-art.htm 8.20 </address> <p> This file is in the public domain, so clarified as of @@ -241,6 +241,17 @@ Supernaw.</td></tr> "The clocks were turned back you remeber/Think it's still November." </td></tr> <tr><td> </td></tr> +<tr><td>Artist</td><td>Ken Nordine</td></tr> +<tr><td>CD</td><td>You're Getting Better: The Word Jazz Dot Masters</td></tr> +<tr><td>Copyright Date</td><td>2005</td></tr> +<tr><td>Label</td><td>Geffen</td></tr> +<tr><td>ID</td><td>B0005171-02</td></tr> +<tr><td>Total Time</td><td>156:22</td></tr> +<tr><td>ADO Rating</td><td>1 star</td></tr> +<tr><td><a href="http://www.allmusic.com/album/youre-getting-better-the-word-jazz-dot-masters+r105931">AMG Rating</a></td><td>4.5 stars</td></tr> +<tr><td>Notes</td><td>Includes the piece "What Time Is It" +("He knew what time it was everywhere...that counted").</td></tr> +<tr><td> </td></tr> <tr><td>TV episode title</td><td>The Lost Hour</td> <tr><td>TV series</td><td><em>Eerie, Indiana</em></td> @@ -406,6 +417,11 @@ IMDB page: http://us.imdb.com/title/tt0137494/ </a>. (Mark Brader, 2009-10-02) </li> +<li> +In "The Todd Couple" episode of "Outsourced" (first aired 2011-02-10), +Manmeet sets up teledates for 6:00 and 9:00; +since one is with a New Yorker and the other with a San Franciscan, +hilarity ensues. </li> </ul> <hr> @@ -467,6 +483,13 @@ or are you trying to dazzle me with your command of time zones?" It is already tomorrow in Australia." (Charles M. Schulz, provided by Steve Summit) </li> +<li> +"I put myself and my staff through this crazy, huge ordeal, all because +I refused to go on at midnight, okay? And so I work, you know, and +then I get this job at eleven, supposed to be a big deal. Then +yesterday daylight [saving] time ended. Right now it's basically +midnight." (Conan O'Brien on the 2010-11-08 premier of "Conan.") +</li> </ul> </body> </html> diff --git a/lib/libc/time/tz-link.htm b/lib/libc/time/tz-link.htm index 26235100b98..f5ce3cb816e 100644 --- a/lib/libc/time/tz-link.htm +++ b/lib/libc/time/tz-link.htm @@ -18,7 +18,7 @@ <body> <h1>Sources for Time Zone and Daylight Saving Time Data</h1> <address> -@(#)tz-link.htm 8.30 +@(#)tz-link.htm 8.32 </address> <p> This file is in the public domain, so clarified as of @@ -96,7 +96,9 @@ href="http://en.wikipedia.org/wiki/Unix_shell">shell</a> commands download these files to a <abbr>GNU</abbr>/Linux or similar host; see the downloaded <code>README</code> file for what to do next.</p> -<pre style="margin-left: 2em"><code><a href="http://www.gnu.org/software/wget/">wget</a> 'ftp://elsie.nci.nih.gov/pub/tz*.tar.gz' +<pre style="margin-left: 2em"><code>mkdir tz +cd tz +<a href="http://www.gnu.org/software/wget/">wget</a> 'ftp://elsie.nci.nih.gov/pub/tz*.tar.gz' <a href="http://www.gnu.org/software/gzip/">gzip</a> -dc tzcode*.tar.gz | <a href="http://www.gnu.org/software/tar/">tar</a> -xf - gzip -dc tzdata*.tar.gz | tar -xf - </code></pre> @@ -316,6 +318,17 @@ WorldClock for Windows and Windows Mobile</a> lets users "see the time in up to 25 locations in the world at once." (From Hans Nieuwenhuis, 2009-11-02.) </li> +<li> +<a href="http://www.relativedata.com/time-zone-master"> +Time Zone Master Basic +</a> "allows people to display multiple desktop clocks, and to +research current and historical time information, as well as times of +astronomical events (sunrise/transit/set, moonrise/transit/set, phases, +season starts) for user-selected dates in the past and future. It can +automatically download, compile and use the tzdata**.gz database files +as they are released to keep the data up to date. The software is +free." (Davie Patte) +</li> </ul> <h2>Other time zone databases</h2> <ul> diff --git a/lib/libc/time/zic.c b/lib/libc/time/zic.c index a8f6086f30e..304711129c0 100644 --- a/lib/libc/time/zic.c +++ b/lib/libc/time/zic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zic.c,v 1.33 2010/09/27 17:45:30 millert Exp $ */ +/* $OpenBSD: zic.c,v 1.34 2011/04/25 13:27:27 millert Exp $ */ /* ** This file is in the public domain, so clarified as of ** 2006-07-17 by Arthur David Olson. @@ -1611,10 +1611,11 @@ const char * const string; mrudst = types[i]; else mrustd = types[i]; for (i = 0; i < typecnt; ++i) - if (writetype[i]) + if (writetype[i]) { if (isdsts[i]) hidst = i; else histd = i; + } if (hidst >= 0 && mrudst >= 0 && hidst != mrudst && gmtoffs[hidst] != gmtoffs[mrudst]) { isdsts[mrudst] = -1; @@ -1863,16 +1864,16 @@ const long gmtoff; register int week; if (rp->r_dycode == DC_DOWGEQ) { - week = 1 + rp->r_dayofmonth / DAYSPERWEEK; - if ((week - 1) * DAYSPERWEEK + 1 != rp->r_dayofmonth) + if ((rp->r_dayofmonth % DAYSPERWEEK) != 1) return -1; + week = 1 + rp->r_dayofmonth / DAYSPERWEEK; } else if (rp->r_dycode == DC_DOWLEQ) { if (rp->r_dayofmonth == len_months[1][rp->r_month]) week = 5; else { - week = 1 + rp->r_dayofmonth / DAYSPERWEEK; - if (week * DAYSPERWEEK - 1 != rp->r_dayofmonth) + if ((rp->r_dayofmonth % DAYSPERWEEK) != 0) return -1; + week = rp->r_dayofmonth / DAYSPERWEEK; } } else return -1; /* "cannot happen" */ (void) snprintf(result, size, "M%d.%d.%d", @@ -2007,6 +2008,7 @@ const int zonecount; register char * envvar; register int max_abbr_len; register int max_envvar_len; + register int prodstic; /* all rules are min to max */ max_abbr_len = 2 + max_format_len + max_abbrvar_len; max_envvar_len = 2 * max_abbr_len + 5 * 9; @@ -2021,6 +2023,7 @@ const int zonecount; timecnt = 0; typecnt = 0; charcnt = 0; + prodstic = zonecount == 1; /* ** Thanks to Earl Chew ** for noting the need to unconditionally initialize startttisstd. @@ -2042,6 +2045,8 @@ const int zonecount; updateminmax(rp->r_loyear); if (rp->r_hiwasnum) updateminmax(rp->r_hiyear); + if (rp->r_lowasnum || rp->r_hiwasnum) + prodstic = FALSE; } } /* @@ -2064,6 +2069,16 @@ wp = ecpyalloc(_("no POSIX environment variable for zone")); if (max_year <= INT_MAX - YEARSPERREPEAT) max_year += YEARSPERREPEAT; else max_year = INT_MAX; + /* + ** Regardless of any of the above, + ** for a "proDSTic" zone which specifies that its rules + ** always have and always will be in effect, + ** we only need one cycle to define the zone. + */ + if (prodstic) { + min_year = 1900; + max_year = min_year + YEARSPERREPEAT; + } } /* ** For the benefit of older systems, |