diff options
author | Stuart Bishop <stuart@stuartbishop.net> | 2013-11-05 17:29:10 +0700 |
---|---|---|
committer | Stuart Bishop <stuart@stuartbishop.net> | 2013-11-05 17:29:10 +0700 |
commit | 634fbd6d116d39e67d7ed03f643bcdc4ea329fca (patch) | |
tree | ab9096098fccfe6baed6b2335db44eef67d147f9 | |
parent | d4d6afff8d2f17021e21f479a28bf3b97ac18f4d (diff) | |
download | pytz-634fbd6d116d39e67d7ed03f643bcdc4ea329fca.tar.gz |
Import 2013h database from IANA
-rw-r--r-- | elsie.nci.nih.gov/src/Makefile | 107 | ||||
-rw-r--r-- | elsie.nci.nih.gov/src/NEWS | 58 | ||||
-rw-r--r-- | elsie.nci.nih.gov/src/africa | 56 | ||||
-rw-r--r-- | elsie.nci.nih.gov/src/localtime.c | 193 | ||||
-rw-r--r-- | elsie.nci.nih.gov/src/southamerica | 15 | ||||
-rw-r--r-- | elsie.nci.nih.gov/src/tz-link.htm | 40 | ||||
-rw-r--r-- | elsie.nci.nih.gov/src/tzselect.ksh | 191 | ||||
-rw-r--r-- | elsie.nci.nih.gov/src/zdump.c | 29 |
8 files changed, 406 insertions, 283 deletions
diff --git a/elsie.nci.nih.gov/src/Makefile b/elsie.nci.nih.gov/src/Makefile index 7653278..0af0d4b 100644 --- a/elsie.nci.nih.gov/src/Makefile +++ b/elsie.nci.nih.gov/src/Makefile @@ -6,7 +6,7 @@ PACKAGE= tzcode # Version numbers of the code and data distributions. -VERSION= 2013g +VERSION= 2013h # Email address for bug reports. BUGEMAIL= tz@iana.org @@ -72,7 +72,6 @@ MANDIR= $(TOPDIR)/man # Library functions are put in an archive in LIBDIR. LIBDIR= $(TOPDIR)/lib -TZLIB= $(LIBDIR)/libtz.a # If you always want time values interpreted as "seconds since the epoch # (not counting leap seconds)", use @@ -247,8 +246,12 @@ ZFLAGS= # The name of a Posix-compliant `awk' on your system. AWK= awk -# The full path name of a Posix-compliant shell that supports the Korn shell's -# 'select' statement, as an extension. These days, Bash is the most popular. +# The full path name of a Posix-compliant shell, preferably one that supports +# the Korn shell's 'select' statement as an extension. +# These days, Bash is the most popular. +# It should be OK to set this to /bin/sh, on platforms where /bin/sh +# lacks 'select' or doesn't completely conform to Posix, but /bin/bash +# is typically nicer if it works. KSHELL= /bin/bash # The path where SGML DTDs are kept. @@ -298,11 +301,13 @@ GZIPFLAGS= -9n cc= cc CC= $(cc) -DTZDIR=\"$(TZDIR)\" -TZCSRCS= zic.c localtime.c asctime.c scheck.c ialloc.c +AR= ar + +# ':' on typical hosts; 'ranlib' on the ancient hosts that still need ranlib. +RANLIB= : + TZCOBJS= zic.o localtime.o asctime.o scheck.o ialloc.o -TZDSRCS= zdump.c localtime.c ialloc.c asctime.o -TZDOBJS= zdump.o localtime.o ialloc.o asctime.c -DATESRCS= date.c localtime.c strftime.c asctime.c +TZDOBJS= zdump.o localtime.o ialloc.o asctime.o DATEOBJS= date.o localtime.o strftime.o asctime.o LIBSRCS= localtime.c asctime.c difftime.c LIBOBJS= localtime.o asctime.o difftime.o @@ -324,10 +329,10 @@ YDATA= $(PRIMARY_YDATA) pacificnew etcetera backward NDATA= systemv factory SDATA= solar87 solar88 solar89 TDATA= $(YDATA) $(NDATA) $(SDATA) -TABDATA= iso3166.tab zone.tab +TABDATA= iso3166.tab zone.tab leapseconds LEAP_DEPS= leapseconds.awk leap-seconds.list DATA= $(YDATA) $(NDATA) $(SDATA) $(TABDATA) \ - leapseconds $(LEAP_DEPS) yearistype.sh + $(LEAP_DEPS) yearistype.sh WEB_PAGES= tz-art.htm tz-link.htm AWK_SCRIPTS= checktab.awk leapseconds.awk MISC= usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \ @@ -340,38 +345,29 @@ ENCHILADA= $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) SHELL= /bin/sh -all: tzselect zic zdump $(LIBOBJS) $(TABDATA) +all: tzselect zic zdump libtz.a $(TABDATA) ALL: all date -install: all $(DATA) $(REDO) $(DESTDIR)$(TZLIB) $(MANS) +install: all $(DATA) $(REDO) $(MANS) + mkdir -p $(DESTDIR)$(ETCDIR) $(DESTDIR)$(TZDIR) \ + $(DESTDIR)$(LIBDIR) \ + $(DESTDIR)$(MANDIR)/man3 $(DESTDIR)$(MANDIR)/man5 \ + $(DESTDIR)$(MANDIR)/man8 $(ZIC) -y $(YEARISTYPE) \ -d $(DESTDIR)$(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES) - -rm -f $(DESTDIR)$(TZDIR)/iso3166.tab \ - $(DESTDIR)$(TZDIR)/zone.tab - cp iso3166.tab zone.tab $(DESTDIR)$(TZDIR)/. - -mkdir $(DESTDIR)$(TOPDIR) $(DESTDIR)$(ETCDIR) + cp -f iso3166.tab zone.tab $(DESTDIR)$(TZDIR)/. cp tzselect zic zdump $(DESTDIR)$(ETCDIR)/. - -mkdir $(DESTDIR)$(TOPDIR) $(DESTDIR)$(MANDIR) \ - $(DESTDIR)$(MANDIR)/man3 $(DESTDIR)$(MANDIR)/man5 \ - $(DESTDIR)$(MANDIR)/man8 - -rm -f $(DESTDIR)$(MANDIR)/man3/newctime.3 \ - $(DESTDIR)$(MANDIR)/man3/newtzset.3 \ - $(DESTDIR)$(MANDIR)/man5/tzfile.5 \ - $(DESTDIR)$(MANDIR)/man8/tzselect.8 \ - $(DESTDIR)$(MANDIR)/man8/zdump.8 \ - $(DESTDIR)$(MANDIR)/man8/zic.8 - cp newctime.3 newtzset.3 $(DESTDIR)$(MANDIR)/man3/. - cp tzfile.5 $(DESTDIR)$(MANDIR)/man5/. - cp tzselect.8 zdump.8 zic.8 $(DESTDIR)$(MANDIR)/man8/. + cp libtz.a $(DESTDIR)$(LIBDIR)/. + $(RANLIB) $(DESTDIR)$(LIBDIR)/libtz.a + cp -f newctime.3 newtzset.3 $(DESTDIR)$(MANDIR)/man3/. + cp -f tzfile.5 $(DESTDIR)$(MANDIR)/man5/. + cp -f tzselect.8 zdump.8 zic.8 $(DESTDIR)$(MANDIR)/man8/. INSTALL: ALL install date.1 - -mkdir $(DESTDIR)$(TOPDIR) $(DESTDIR)$(BINDIR) + mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1 cp date $(DESTDIR)$(BINDIR)/. - -mkdir $(DESTDIR)$(TOPDIR) $(DESTDIR)$(MANDIR) \ - $(DESTDIR)$(MANDIR)/man1 - -rm -f $(DESTDIR)$(MANDIR)/man1/date.1 - cp date.1 $(DESTDIR)$(MANDIR)/man1/. + cp -f date.1 $(DESTDIR)$(MANDIR)/man1/. version.h: (echo 'static char const PKGVERSION[]="($(PACKAGE)) ";' && \ @@ -426,11 +422,9 @@ posix_right: posix_only leapseconds zones: $(REDO) -$(DESTDIR)$(TZLIB): $(LIBOBJS) - -mkdir -p $(DESTDIR)$(TOPDIR) $(DESTDIR)$(LIBDIR) - ar ru $@ $(LIBOBJS) - if [ -x /usr/ucb/ranlib ] || [ -x /usr/bin/ranlib ]; \ - then ranlib $@ ; fi +libtz.a: $(LIBOBJS) + $(AR) ru $@ $(LIBOBJS) + $(RANLIB) $@ date: $(DATEOBJS) $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DATEOBJS) $(LDLIBS) @@ -459,14 +453,14 @@ check_web: $(WEB_PAGES) clean_misc: rm -f core *.o *.out \ - date leapseconds tzselect version.h zdump zic yearistype + date tzselect version.h zdump zic yearistype clean: clean_misc - rm -f -r tzpublic + rm -fr tzpublic maintainer-clean: clean @echo 'This command is intended for maintainers to use; it' @echo 'deletes files that may need special tools to rebuild.' - rm -f $(MANTXTS) *.asc *.tar.gz + rm -f leapseconds $(MANTXTS) *.asc *.tar.gz names: @echo $(ENCHILADA) @@ -491,21 +485,23 @@ $(MANTXTS): workman.sh # and if the files have not changed since then. # This uses GNU 'touch' syntax 'touch -d@N FILE', # where N is the number of seconds since 1970. -# If git or GNU 'touch' is absent, do nothing and fail. +# If git or GNU 'touch' is absent, don't bother to sync with git timestamps. # Also, set the timestamp of each prebuilt file like 'leapseconds' # to be the maximum of the files it depends on. set-timestamps.out: $(ENCHILADA) rm -f $@ - -files=`git ls-files $(ENCHILADA)` && \ - touch -md @1 test.out && rm -f test.out && \ - for file in $$files; do \ - if git diff --quiet $$file; then \ - time=`git log -1 --format='tformat:%ct' $$file` && \ - touch -cmd @$$time $$file; \ - else \ - echo >&2 "$$file: warning: does not match repository"; \ - fi || exit; \ - done + if files=`git ls-files $(ENCHILADA)` && \ + touch -md @1 test.out; then \ + rm -f test.out && \ + for file in $$files; do \ + if git diff --quiet $$file; then \ + time=`git log -1 --format='tformat:%ct' $$file` && \ + touch -cmd @$$time $$file; \ + else \ + echo >&2 "$$file: warning: does not match repository"; \ + fi || exit; \ + done; \ + fi touch -cmr `ls -t $(LEAP_DEPS) | sed 1q` leapseconds for file in `ls $(MANTXTS) | sed 's/\.txt$$//'`; do \ touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \ @@ -524,15 +520,14 @@ check_public: $(ENCHILADA) $(zic) -v -d tzpublic $$i 2>&1 || exit; \ done $(zic) -v -d tzpublic $(TDATA) - rm -f -r tzpublic + rm -fr tzpublic # Check that the code works under various alternative # implementations of time_t. check_time_t_alternatives: - mkdir tzpublic zones=`$(AWK) '/^[^#]/ { print $$3 }' <zone.tab` && \ for type in $(TIME_T_ALTERNATIVES); do \ - mkdir tzpublic/$$type && \ + mkdir -p tzpublic/$$type && \ make clean_misc && \ make TOPDIR=`pwd`/tzpublic/$$type \ CFLAGS='$(CFLAGS) -Dtime_tz='"'$$type'" \ @@ -553,7 +548,7 @@ check_time_t_alternatives: diff -u tzpublic/int64_t.out tzpublic/$$type.out \ || exit; \ done - rm -f -r tzpublic + rm -fr tzpublic tarballs: tzcode$(VERSION).tar.gz tzdata$(VERSION).tar.gz diff --git a/elsie.nci.nih.gov/src/NEWS b/elsie.nci.nih.gov/src/NEWS index 8166141..134a747 100644 --- a/elsie.nci.nih.gov/src/NEWS +++ b/elsie.nci.nih.gov/src/NEWS @@ -1,5 +1,63 @@ News for the tz database +Release 2013h - 2013-10-25 15:32:32 -0700 + + Changes affecting current and future time stamps: + + Libya has switched its time zone back to UTC+2 without DST, + instead of UTC+1 with DST. (Thanks to Even Scharning.) + + Western Sahara (Africa/El_Aaiun) uses Morocco's DST rules. + (Thanks to Gwillim Law.) + + Changes affecting future time stamps: + + Acre and (we guess) western Amazonas will switch from UTC-4 to UTC-5 + on 2013-11-10. This affects America/Rio_Branco and America/Eirunepe. + (Thanks to Steffen Thorsen.) + + Add entries for DST transitions in Morocco in the year 2038. + This avoids some year-2038 glitches introduced in 2013g. + (Thanks to Yoshito Umaoka for reporting the problem.) + + Changes affecting API + + The 'tzselect' command no longer requires the 'select' command, + and should now work with /bin/sh on more platforms. It also works + around a bug in BusyBox awk before version 1.21.0. (Thanks to + Patrick 'P. J.' McDermott.) + + Changes affecting code + + Fix localtime overflow bugs with 32-bit unsigned time_t. + + zdump no longer assumes sscanf returns maximal values on overflow. + + Changes affecting the build procedure + + The builder can specify which programs to use, if any, instead of + 'ar' and 'ranlib', and libtz.a is now built locally before being + installed. (Thanks to Michael Forney.) + + A dependency typo in the 'zdump' rule has been fixed. + (Thanks to Andrew Paprocki.) + + The Makefile has been simplified by assuming that 'mkdir -p' and 'cp -f' + work as specified by POSIX.2-1992 or later; this is portable nowadays. + + 'make clean' no longer removes 'leapseconds', since it's + host-independent and is part of the distribution. + + The unused makefile macros TZCSRCS, TZDSRCS, DATESRCS have been removed. + + Changes affecting documentation and commentary + + tz-link.htm now mentions TC TIMEZONE's draft timezone service protocol + (thanks to Mike Douglass) and TimezoneJS.Date (thanks to Jim Fehrle). + + Update URLs in tz-link page. Add URLs for Microsoft Windows, since + 8.1 introduces tz support. Remove URLs for Tru64 and UnixWare (no + longer maintained) and for old advisories. SOFA now does C. Release 2013g - 2013-09-30 21:08:26 -0700 diff --git a/elsie.nci.nih.gov/src/africa b/elsie.nci.nih.gov/src/africa index 20b00eb..029e5c2 100644 --- a/elsie.nci.nih.gov/src/africa +++ b/elsie.nci.nih.gov/src/africa @@ -451,6 +451,14 @@ Zone Africa/Monrovia -0:43:08 - LMT 1882 # (either two days before them or five days after them, so as to fall on # lastFri instead of lastSun). +# From Even Scharning (2013-10-25): +# The scheduled end of DST in Libya on Friday, October 25, 2013 was +# cancelled yesterday.... +# http://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/ +# +# From Paul Eggert (2013-10-25): +# For now, assume they're reverting to the pre-2012 rules of permanent UTC+2. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Libya 1951 only - Oct 14 2:00 1:00 S Rule Libya 1952 only - Jan 1 0:00 0 - @@ -467,8 +475,8 @@ Rule Libya 1987 1989 - Apr 1 0:00 1:00 S Rule Libya 1987 1989 - Oct 1 0:00 0 - Rule Libya 1997 only - Apr 4 0:00 1:00 S Rule Libya 1997 only - Oct 4 0:00 0 - -Rule Libya 2013 max - Mar lastFri 1:00 1:00 S -Rule Libya 2013 max - Oct lastFri 2:00 0 - +Rule Libya 2013 only - Mar lastFri 1:00 1:00 S +Rule Libya 2013 only - Oct lastFri 2:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Tripoli 0:52:44 - LMT 1920 1:00 Libya CE%sT 1959 @@ -479,7 +487,8 @@ Zone Africa/Tripoli 0:52:44 - LMT 1920 2:00 - EET 1996 Sep 30 1:00 Libya CE%sT 1997 Oct 4 2:00 - EET 2012 Nov 10 2:00 - 1:00 Libya CE%sT + 1:00 Libya CE%sT 2013 Oct 25 2:00 + 2:00 - EET # Madagascar # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -684,15 +693,6 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou # http://www.google.com/search?hl=en&q=Conseil+de+gouvernement+maroc+heure+avance&btnG=Search # </a> -# From Alex Krivenyshev (2008-05-09): -# Is Western Sahara (part which administrated by Morocco) going to follow -# Morocco DST changes? Any information? What about other part of -# Western Sahara - under administration of POLISARIO Front (also named -# SADR Saharawi Arab Democratic Republic)? - -# From Arthur David Olson (2008-05-09): -# XXX--guess that it is only Morocco for now; guess only 2008 for now. - # From Steffen Thorsen (2008-08-27): # Morocco will change the clocks back on the midnight between August 31 # and September 1. They originally planned to observe DST to near the end @@ -868,13 +868,13 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou # Another source (specifying the time for start and end in the decree): # http://www.lemag.ma/Heure-d-ete-au-Maroc-jusqu-au-27-octobre_a75620.html -# From Paul Eggert (2013-09-30): +# From Paul Eggert (2013-10-03): # To estimate what the Moroccan government will do in future years, -# transition dates for 2014 through 2037 were determined by running +# transition dates for 2014 through 2038 were determined by running # the following program under GNU Emacs 24.3: # # (let ((islamic-year 1435)) -# (while (< islamic-year 1460) +# (while (< islamic-year 1461) # (let ((a # (calendar-gregorian-from-absolute # (calendar-islamic-to-absolute (list 9 1 islamic-year)))) @@ -894,9 +894,13 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou # all transitions removed for 2026-2035, where the estimated Ramadan # falls entirely outside daylight-saving time; and with fall-back # transitions removed for 2036-2037, where the normal fall-back -# date falls during the estimated Ramadan. Problems continue after that, -# but 32-bit time_t values roll around in 2038 so for now do not worry -# about dates after 2037. +# date falls during the estimated Ramadan. Normally, the table would +# stop after 2037 because 32-bit time_t values roll around early in 2038, +# but that would imply a prediction of perpetual DST after March 2038 +# due to the year-2037 glitches. So, this table instead stops after +# 2038, the first non-glitchy year after the 32-bit rollover. +# An advantage of stopping after 2038 is that it lets zic guess +# TZ='WET0WEST,M3.5.0,M10.5.0/3' for time stamps far in the future. # RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -955,16 +959,30 @@ Rule Morocco 2025 only - Mar 31 2:00 1:00 S Rule Morocco 2026 max - Mar lastSun 2:00 1:00 S Rule Morocco 2036 only - Oct 21 3:00 0 - Rule Morocco 2037 only - Oct 11 3:00 0 - +Rule Morocco 2038 only - Sep 30 3:00 0 - +Rule Morocco 2038 only - Oct 30 2:00 1:00 S +Rule Morocco 2038 max - Oct lastSun 3:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26 0:00 Morocco WE%sT 1984 Mar 16 1:00 - CET 1986 0:00 Morocco WE%sT + # Western Sahara +# +# From Gwillim Law (2013-10-22): +# A correspondent who is usually well informed about time zone matters +# ... says that Western Sahara observes daylight saving time, just as +# Morocco does. +# +# From Paul Eggert (2013-10-23): +# Assume that this has been true since Western Sahara switched to GMT, +# since most of it was then controlled by Morocco. + Zone Africa/El_Aaiun -0:52:48 - LMT 1934 Jan -1:00 - WAT 1976 Apr 14 - 0:00 - WET + 0:00 Morocco WE%sT # Mozambique # Zone NAME GMTOFF RULES FORMAT [UNTIL] diff --git a/elsie.nci.nih.gov/src/localtime.c b/elsie.nci.nih.gov/src/localtime.c index 8c8edf3..dcfc1cd 100644 --- a/elsie.nci.nih.gov/src/localtime.c +++ b/elsie.nci.nih.gov/src/localtime.c @@ -131,7 +131,7 @@ struct rule { */ static int_fast32_t detzcode(const char * codep); -static time_t detzcode64(const char * codep); +static int_fast64_t detzcode64(const char * codep); static int differ_by_repeat(time_t t1, time_t t0); static const char * getzname(const char * strp) ATTRIBUTE_PURE; static const char * getqzname(const char * strp, const int delim) @@ -149,6 +149,7 @@ static struct tm * localsub(const time_t * timep, int_fast32_t offset, static int increment_overflow(int * number, int delta); static int leaps_thru_end_of(int y) ATTRIBUTE_PURE; static int increment_overflow32(int_fast32_t * number, int delta); +static int increment_overflow_time(time_t *t, int_fast32_t delta); static int normalize_overflow32(int_fast32_t * tensptr, int * unitsptr, int base); static int normalize_overflow(int * tensptr, int * unitsptr, @@ -170,8 +171,8 @@ static struct tm * timesub(const time_t * timep, int_fast32_t offset, const struct state * sp, struct tm * tmp); static int tmcomp(const struct tm * atmp, const struct tm * btmp); -static time_t transtime(time_t janfirst, int year, - const struct rule * rulep, int_fast32_t offset) +static int_fast32_t transtime(int year, const struct rule * rulep, + int_fast32_t offset) ATTRIBUTE_PURE; static int typesequiv(const struct state * sp, int a, int b); static int tzload(const char * name, struct state * sp, @@ -235,15 +236,15 @@ detzcode(const char *const codep) return result; } -static time_t +static int_fast64_t detzcode64(const char *const codep) { - register time_t result; + register int_fast64_t result; register int i; - result = (codep[0] & 0x80) ? (~(int_fast64_t) 0) : 0; + result = (codep[0] & 0x80) ? -1 : 0; for (i = 0; i < 8; ++i) - result = result * 256 + (codep[i] & 0xff); + result = (result << 8) | (codep[i] & 0xff); return result; } @@ -391,6 +392,7 @@ tzload(register const char *name, register struct state *const sp, for (stored = 4; stored <= 8; stored *= 2) { int ttisstdcnt; int ttisgmtcnt; + int timecnt; ttisstdcnt = (int) detzcode(up->tzhead.tzh_ttisstdcnt); ttisgmtcnt = (int) detzcode(up->tzhead.tzh_ttisgmtcnt); @@ -415,16 +417,37 @@ tzload(register const char *name, register struct state *const sp, ttisstdcnt + /* ttisstds */ ttisgmtcnt) /* ttisgmts */ goto oops; + timecnt = 0; for (i = 0; i < sp->timecnt; ++i) { - sp->ats[i] = (stored == 4) ? - detzcode(p) : detzcode64(p); + int_fast64_t at + = stored == 4 ? detzcode(p) : detzcode64(p); + sp->types[i] = ((TYPE_SIGNED(time_t) + ? time_t_min <= at + : 0 <= at) + && at <= time_t_max); + if (sp->types[i]) { + if (i && !timecnt && at != time_t_min) { + /* + ** Keep the earlier record, but tweak + ** it so that it starts with the + ** minimum time_t value. + */ + sp->types[i - 1] = 1; + sp->ats[timecnt++] = time_t_min; + } + sp->ats[timecnt++] = at; + } p += stored; } + timecnt = 0; for (i = 0; i < sp->timecnt; ++i) { - sp->types[i] = (unsigned char) *p++; - if (sp->types[i] >= sp->typecnt) + unsigned char typ = *p++; + if (sp->typecnt <= typ) goto oops; + if (sp->types[i]) + sp->types[timecnt++] = typ; } + sp->timecnt = timecnt; for (i = 0; i < sp->typecnt; ++i) { register struct ttinfo * ttisp; @@ -479,44 +502,6 @@ tzload(register const char *name, register struct state *const sp, } } /* - ** Out-of-sort ats should mean we're running on a - ** signed time_t system but using a data file with - ** unsigned values (or vice versa). - */ - for (i = 0; i < sp->timecnt; ++i) - if ((i < sp->timecnt - 1 && - sp->ats[i] > sp->ats[i + 1]) || - (i == sp->timecnt - 1 && !TYPE_SIGNED(time_t) && - sp->ats[i] > - ((stored == 4) ? INT32_MAX : INT64_MAX))) { - if (TYPE_SIGNED(time_t)) { - /* - ** Ignore the end (easy). - */ - sp->timecnt = i + 1; - } else { - /* - ** Ignore the beginning (harder). - */ - register int j; - - /* - ** Keep the record right before the - ** epoch boundary, - ** but tweak it so that it starts - ** right with the epoch - ** (thanks to Doug Bailey). - */ - sp->ats[i] = 0; - for (j = 0; j + i < sp->timecnt; ++j) { - sp->ats[j] = sp->ats[j + i]; - sp->types[j] = sp->types[j + i]; - } - sp->timecnt = j; - } - break; - } - /* ** If this is an old file, we're done. */ if (up->tzhead.tzh_version[0] == '\0') @@ -525,9 +510,9 @@ tzload(register const char *name, register struct state *const sp, for (i = 0; i < nread; ++i) up->buf[i] = p[i]; /* - ** If this is a narrow time_t system, we're done. + ** If this is a signed narrow time_t system, we're done. */ - if (stored >= (int) sizeof(time_t)) + if (TYPE_SIGNED(time_t) && stored >= (int) sizeof(time_t)) break; } if (doextend && nread > 2 && @@ -841,17 +826,16 @@ getrule(const char *strp, register struct rule *const rulep) } /* -** Given the Epoch-relative time of January 1, 00:00:00 UTC, in a year, the -** year, a rule, and the offset from UT at the time that rule takes effect, -** calculate the Epoch-relative time that rule takes effect. +** Given a year, a rule, and the offset from UT at the time that rule takes +** effect, calculate the year-relative time that rule takes effect. */ -static time_t -transtime(const time_t janfirst, const int year, - register const struct rule *const rulep, const int_fast32_t offset) +static int_fast32_t +transtime(const int year, register const struct rule *const rulep, + const int_fast32_t offset) { register int leapyear; - register time_t value; + register int_fast32_t value; register int i; int d, m1, yy0, yy1, yy2, dow; @@ -867,7 +851,7 @@ transtime(const time_t janfirst, const int year, ** add SECSPERDAY times the day number-1 to the time of ** January 1, midnight, to get the day. */ - value = janfirst + (rulep->r_day - 1) * SECSPERDAY; + value = (rulep->r_day - 1) * SECSPERDAY; if (leapyear && rulep->r_day >= 60) value += SECSPERDAY; break; @@ -878,16 +862,13 @@ transtime(const time_t janfirst, const int year, ** Just add SECSPERDAY times the day number to the time of ** January 1, midnight, to get the day. */ - value = janfirst + rulep->r_day * SECSPERDAY; + value = rulep->r_day * SECSPERDAY; break; case MONTH_NTH_DAY_OF_WEEK: /* ** Mm.n.d - nth "dth day" of month m. */ - value = janfirst; - for (i = 0; i < rulep->r_mon - 1; ++i) - value += mon_lengths[leapyear][i] * SECSPERDAY; /* ** Use Zeller's Congruence to get day-of-week of first day of @@ -920,13 +901,15 @@ transtime(const time_t janfirst, const int year, /* ** "d" is the day-of-month (zero-origin) of the day we want. */ - value += d * SECSPERDAY; + value = d * SECSPERDAY; + for (i = 0; i < rulep->r_mon - 1; ++i) + value += mon_lengths[leapyear][i] * SECSPERDAY; break; } /* - ** "value" is the Epoch-relative time of 00:00:00 UT on the day in - ** question. To get the Epoch-relative time of the specified local + ** "value" is the year-relative time of 00:00:00 UT on the day in + ** question. To get the year-relative time of the specified local ** time on that day, add the transition time and the current offset ** from UT. */ @@ -948,8 +931,6 @@ tzparse(const char *name, register struct state *const sp, size_t dstlen; int_fast32_t stdoffset; int_fast32_t dstoffset; - register time_t * atp; - register unsigned char * typep; register char * cp; register int load_result; static struct ttinfo zttinfo; @@ -1009,9 +990,8 @@ tzparse(const char *name, register struct state *const sp, struct rule end; register int year; register int yearlim; - register time_t janfirst; - time_t starttime; - time_t endtime; + register int timecnt; + time_t janfirst; ++name; if ((name = getrule(name, &start)) == NULL) @@ -1033,45 +1013,46 @@ tzparse(const char *name, register struct state *const sp, sp->ttis[1].tt_gmtoff = -stdoffset; sp->ttis[1].tt_isdst = 0; sp->ttis[1].tt_abbrind = 0; - atp = sp->ats; - typep = sp->types; + timecnt = 0; janfirst = 0; yearlim = EPOCH_YEAR + YEARSPERREPEAT; for (year = EPOCH_YEAR; year < yearlim; year++) { - int_fast32_t yearsecs; - - starttime = transtime(janfirst, year, &start, - stdoffset); - endtime = transtime(janfirst, year, &end, - dstoffset); - yearsecs = (year_lengths[isleap(year)] - * SECSPERDAY); - if (starttime > endtime + int_fast32_t + starttime = transtime(year, &start, stdoffset), + endtime = transtime(year, &end, dstoffset); + int_fast32_t + yearsecs = (year_lengths[isleap(year)] + * SECSPERDAY); + int reversed = endtime < starttime; + if (reversed) { + int_fast32_t swap = starttime; + starttime = endtime; + endtime = swap; + } + if (reversed || (starttime < endtime && (endtime - starttime < (yearsecs + (stdoffset - dstoffset))))) { - if (&sp->ats[TZ_MAX_TIMES - 2] < atp) + if (TZ_MAX_TIMES - 2 < timecnt) break; yearlim = year + YEARSPERREPEAT + 1; - if (starttime > endtime) { - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - } else { - *atp++ = starttime; - *typep++ = 0; /* DST begins */ - *atp++ = endtime; - *typep++ = 1; /* DST ends */ - } + sp->ats[timecnt] = janfirst; + if (increment_overflow_time + (&sp->ats[timecnt], starttime)) + break; + sp->types[timecnt++] = reversed; + sp->ats[timecnt] = janfirst; + if (increment_overflow_time + (&sp->ats[timecnt], endtime)) + break; + sp->types[timecnt++] = !reversed; } - if (time_t_max - janfirst < yearsecs) + if (increment_overflow_time(&janfirst, yearsecs)) break; - janfirst += yearsecs; } - sp->timecnt = atp - sp->ats; - if (!sp->timecnt) + sp->timecnt = timecnt; + if (!timecnt) sp->typecnt = 1; /* Perpetual DST. */ } else { register int_fast32_t theirstdoffset; @@ -1644,6 +1625,22 @@ increment_overflow32(int_fast32_t *const lp, int const m) } static int +increment_overflow_time(time_t *tp, int_fast32_t j) +{ + /* + ** This is like + ** 'if (! (time_t_min <= *tp + j && *tp + j <= time_t_max)) ...', + ** except that it does the right thing even if *tp + j would overflow. + */ + if (! (j < 0 + ? (TYPE_SIGNED(time_t) ? time_t_min - j <= *tp : -1 - j < *tp) + : *tp <= time_t_max - j)) + return TRUE; + *tp += j; + return FALSE; +} + +static int normalize_overflow(int *const tensptr, int *const unitsptr, const int base) { register int tensdelta; diff --git a/elsie.nci.nih.gov/src/southamerica b/elsie.nci.nih.gov/src/southamerica index 3b25ce3..2d77bf7 100644 --- a/elsie.nci.nih.gov/src/southamerica +++ b/elsie.nci.nih.gov/src/southamerica @@ -851,6 +851,15 @@ Zone America/La_Paz -4:32:36 - LMT 1890 # We will keep this article updated when this is confirmed: # http://www.timeanddate.com/news/time/brazil-starts-dst-2013.html +# From Steffen Thorsen (2013-10-17): +# http://www.timeanddate.com/news/time/acre-amazonas-change-time-zone.html +# Senator Jorge Viana announced that Acre will change time zone on November 10. +# He did not specify the time of the change, nor if western parts of Amazonas +# will change as well. +# +# From Paul Eggert (2013-10-17): +# For now, assume western Amazonas will change as well. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Decree <a href="http://pcdsh01.on.br/HV20466.htm">20,466</a> (1931-10-01) # Decree <a href="http://pcdsh01.on.br/HV21896.htm">21,896</a> (1932-01-10) @@ -1139,13 +1148,15 @@ Zone America/Eirunepe -4:39:28 - LMT 1914 -5:00 - ACT 1993 Sep 28 -5:00 Brazil AC%sT 1994 Sep 22 -5:00 - ACT 2008 Jun 24 00:00 - -4:00 - AMT + -4:00 - AMT 2013 Nov 10 + -5:00 - ACT # # Acre (AC) Zone America/Rio_Branco -4:31:12 - LMT 1914 -5:00 Brazil AC%sT 1988 Sep 12 -5:00 - ACT 2008 Jun 24 00:00 - -4:00 - AMT + -4:00 - AMT 2013 Nov 10 + -5:00 - ACT # Chile diff --git a/elsie.nci.nih.gov/src/tz-link.htm b/elsie.nci.nih.gov/src/tz-link.htm index 6752cfc..f3665be 100644 --- a/elsie.nci.nih.gov/src/tz-link.htm +++ b/elsie.nci.nih.gov/src/tz-link.htm @@ -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="2013-09-05"> +<meta name="DC.Date" content="2013-10-21"> <meta name="DC.Description" content="Sources of information about time zones and daylight saving time"> <meta name="DC.Identifier" @@ -51,12 +51,11 @@ title="DJ's GNU Programming Platform">DJGPP</abbr></a>, <a href="http://ibm.com/aix">AIX</a>, <a href="http://en.wikipedia.org/wiki/BlackBerry_10">BlackBerry 10</a>, <a href="http://www.apple.com/ios/">iOS</a>, +<a href="http://windows.microsoft.com/">Microsoft Windows</a>, <a href="http://h71000.www7.hp.com/">OpenVMS</a>, <a href="http://oracle.com/database">Oracle Database</a>, -<a href="http://www.apple.com/osx/">OS X</a>, -<a href="http://oracle.com/solaris">Solaris</a>, -<a href="http://h30097.www3.hp.com/">Tru64</a>, and -<a href="http://sco.com/products/unixware">UnixWare</a>.</p> +<a href="http://www.apple.com/osx/">OS X</a>, and +<a href="http://oracle.com/solaris">Solaris</a>.</p> <p> Each location in the database represents a national region where all clocks keeping local time have agreed since 1970. @@ -158,7 +157,7 @@ href="http://convertit.com/Go/ConvertIt/World_Time/Current_Time.ASP">Current Time in 1000 Places</a> uses descriptions of the values.</li> <li><a href="http://www.timezoneconverter.com/cgi-bin/tzc.tzc">Time Zone Converter</a> uses a pulldown menu.</li> -<li><a href="http://home.tiscali.nl/~t876506/TZworld.html">Complete +<li><a href="http://home.telfort.nl/~t876506/TZworld.html">Complete timezone information for all countries</a> displays tables of DST rules. <li><a href="http://timeanddate.com/worldclock/">The World Clock – Time Zones</a> lets you sort zone names and convert times.</li> @@ -168,7 +167,7 @@ multiple timezones.</li> <li><a href="http://daylight-savings-time.info/">Daylight Saving Time info</a> shows a graph of time difference versus time for any pair of locations.</li> -<li>The <a href="http://worldtimeengine.com/">World Time Engine</a> +<li><a href="http://worldtime.io/">worldtime.io</a> also contains data about time zone boundaries; it supports queries via place names and shows location maps.</li> <li><a href="http://simpletimerclocks.mozdev.org/">Simple Timer + Clocks</a> @@ -187,10 +186,10 @@ Consortium</a> is promoting further work in this area. <a href="http://calconnect.org/publications/icalendartimezoneproblemsandrecommendationsv1.0.pdf">iCalendar TIMEZONE Problems and Recommendations</a> offers guidelines and recommendations for the use of VTIMEZONE and <code>tz</code>.</li> -<li><a href="http://calconnect.org/dstlinks.shtml">Extended Daylight -Saving Time Links, Advisories and Changes</a> lists vendor material on 2007 -U.S. daylight saving time changes.</li> -<li><a +<li>CalConnect's <a href="http://calconnect.org/tc-timezone.shtml">TIMEZONE +Technical Committee</a> has developed +a <a href="http://tools.ietf.org/html/draft-douglass-timezone-service-08">draft +timezone service protocol</a>. The committee's earlier <a href="http://calconnect.org/publications/timezoneregistryandservicerecommendationsv1.0.pdf">Timezone Registry and Service Recommendations</a> discusses a strategy for defining and deploying a time zone @@ -241,12 +240,19 @@ has a compiler from <code>tz</code> source into an <abbr>ICU</abbr>-specific format. <abbr>ICU</abbr> is freely available under a <abbr title="Berkeley Software Distribution">BSD</abbr>-style license.</li> -<li><a href="http://joda-time.sourceforge.net/">Joda Time - Java date +<li><a href="http://www.joda.org/joda-time/">Joda Time - Java date and time <abbr title="Application Program Interface">API</abbr></a> contains a class <code>org.joda.time.tz.ZoneInfoCompiler</code> that compiles <code>tz</code> source into a Joda-specific binary format. Joda Time is freely available under a <abbr>BSD</abbr>-style license.</li> +<li><a href="https://github.com/mde/timezone-js">TimezoneJS.Date</a> +is a <a href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a> +library that parses <code>tz</code> source files and interprets time +stamps using an API that is upward compatible with standard JavaScript +Dates. It is freely available under +the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache +License</a>.</li> <li><a href="http://pytz.sourceforge.net">pytz - World Timezone Definitions for Python</a> compiles <code>tz</code> source into <a href="http://python.org/">Python</a>. @@ -295,7 +301,7 @@ It is freely available under the same terms as Perl public-domain <a href="https://github.com/dbaron/tz.js">tz.js</a> library contains a Python tool that converts <code>tz</code> binary data into <a href="http://www.json.org/">JSON</a>-format data suitable for use -in its <a href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a> library for time zone conversion. Dates before 1970 +in its JavaScript library for time zone conversion. Dates before 1970 are not supported.</li> </ul> <h2>Other <code>tz</code>-based time zone software</h2> @@ -403,7 +409,7 @@ geospatial query operators to shapefiles' data.</li> <li><a href="http://statoids.com/statoids.html">Administrative Divisions of Countries ("Statoids")</a> contains lists of political subdivision data related to time zones.</li> -<li><a href="http://home.tiscali.nl/~t876506/Multizones.html">Time +<li><a href="http://home.telfort.nl/~t876506/Multizones.html">Time zone boundaries for multizone countries</a> summarizes legal boundaries between time zones within countries.</li> <li>Manifold.net's <a @@ -479,8 +485,8 @@ href="http://www.nrc-cnrc.gc.ca/eng/services/time/time_zones.html">time zones & daylight saving time</a>.</dd> <dt>Chile</dt> <dd>The Chilean Hydrographic and Oceanographic Service publishes a <a -href="http://www.horaoficial.cl/horaof.htm" hreflang="es"> history of -official time (in Spanish)</a>.</dd> +href="http://www.horaoficial.cl/historia_hora.html" hreflang="es">history of +Chile's official time (in Spanish)</a>.</dd> <dt>Germany</dt> <dd>The National Institute for Science and Technology maintains the <a href="http://www.ptb.de/cms/en/fachabteilungen/abt4/fb-44/ag-441/realisation-of-legal-time-in-germany.html">Realisation of @@ -557,7 +563,7 @@ Scales</a> goes into more detail, particularly for historical variants.</li> title="International Astronomical Union">IAU</abbr></a>'s <a href="http://www.iausofa.org/"><abbr title="Standards Of Fundamental Astronomy">SOFA</abbr></a> -initiative publishes Fortran +initiative publishes C and Fortran code for converting among time scales like <abbr title="International Atomic Time">TAI</abbr>, <abbr>TDB</abbr>, <abbr>TDT</abbr> and diff --git a/elsie.nci.nih.gov/src/tzselect.ksh b/elsie.nci.nih.gov/src/tzselect.ksh index 1934dd0..9d70691 100644 --- a/elsie.nci.nih.gov/src/tzselect.ksh +++ b/elsie.nci.nih.gov/src/tzselect.ksh @@ -11,7 +11,7 @@ REPORT_BUGS_TO=tz@iana.org # Porting notes: # -# This script requires a Posix-like shell with the extension of a +# This script requires a Posix-like shell and prefers the extension of a # 'select' statement. The 'select' statement was introduced in the # Korn shell and is available in Bash and other shell implementations. # If your host lacks both Bash and the Korn shell, you can get their @@ -21,6 +21,10 @@ REPORT_BUGS_TO=tz@iana.org # Korn Shell <http://www.kornshell.com/> # Public Domain Korn Shell <http://www.cs.mun.ca/~michael/pdksh/> # +# For portability to Solaris 9 /bin/sh this script avoids some POSIX +# features and common extensions, such as $(...) (which works sometimes +# but not others), $((...)), and $10. +# # This script also uses several features of modern awk programs. # If your host lacks awk, or has an old awk that does not conform to Posix, # you can use either of the following free programs instead: @@ -31,7 +35,7 @@ REPORT_BUGS_TO=tz@iana.org # Specify default values for environment variables if they are unset. : ${AWK=awk} -: ${TZDIR=$(pwd)} +: ${TZDIR=`pwd`} # Check for awk Posix compliance. ($AWK -v x=y 'BEGIN { exit 123 }') </dev/null >/dev/null 2>&1 @@ -67,6 +71,74 @@ Options: Report bugs to $REPORT_BUGS_TO." +# Ask the user to select from the function's arguments, +# and assign the selected argument to the variable 'select_result'. +# Exit on EOF or I/O error. Use the shell's 'select' builtin if available, +# falling back on a less-nice but portable substitute otherwise. +if + case $BASH_VERSION in + ?*) : ;; + '') + # '; exit' should be redundant, but Dash doesn't properly fail without it. + (eval 'set --; select x; do break; done; exit') 2>/dev/null + esac +then + # Do this inside 'eval', as otherwise the shell might exit when parsing it + # even though it is never executed. + eval ' + doselect() { + select select_result + do + case $select_result in + "") echo >&2 "Please enter a number in range." ;; + ?*) break + esac + done || exit + } + + # Work around a bug in bash 1.14.7 and earlier, where $PS3 is sent to stdout. + case $BASH_VERSION in + [01].*) + case `echo 1 | (select x in x; do break; done) 2>/dev/null` in + ?*) PS3= + esac + esac + ' +else + doselect() { + # Field width of the prompt numbers. + select_width=`expr $# : '.*'` + + select_i= + + while : + do + case $select_i in + '') + select_i=0 + for select_word + do + select_i=`expr $select_i + 1` + printf >&2 "%${select_width}d) %s\\n" $select_i "$select_word" + done ;; + *[!0-9]*) + echo >&2 'Please enter a number in range.' ;; + *) + if test 1 -le $select_i && test $select_i -le $#; then + shift `expr $select_i - 1` + select_result=$1 + break + fi + echo >&2 'Please enter a number in range.' + esac + + # Prompt and read input. + printf >&2 %s "${PS3-#? }" + read select_i || exit + done + } +fi + while getopts c:n:-: opt do case $opt$OPTARG in @@ -85,7 +157,7 @@ do esac done -shift $((OPTIND-1)) +shift `expr $OPTIND - 1` case $# in 0) ;; *) echo >&2 "$0: $1: unknown argument"; exit 1 ;; @@ -107,11 +179,6 @@ newline=' IFS=$newline -# Work around a bug in bash 1.14.7 and earlier, where $PS3 is sent to stdout. -case $(echo 1 | (select x in x; do break; done) 2>/dev/null) in -?*) PS3= -esac - # Awk script to read a time zone table and output the same table, # with each column preceded by its distance from 'here'. output_distances=' @@ -191,8 +258,9 @@ while echo >&2 'Please select a continent, ocean, "coord", or "TZ".' - quoted_continents=$( - $AWK -F'\t' ' + quoted_continents=` + $AWK ' + BEGIN { FS = "\t" } /^[^#]/ { entry = substr($3, 1, index($3, "/") - 1) if (entry == "America") @@ -205,30 +273,21 @@ while sort -u | tr '\n' ' ' echo '' - ) + ` eval ' - select continent in '"$quoted_continents"' \ + doselect '"$quoted_continents"' \ "coord - I want to use geographical coordinates." \ "TZ - I want to specify the time zone using the Posix TZ format." - do - case $continent in - "") - echo >&2 "Please enter a number in range.";; - ?*) - case $continent in - Americas) continent=America;; - *" "*) continent=$(expr "$continent" : '\''\([^ ]*\)'\'') - esac - break - esac - done + continent=$select_result + case $continent in + Americas) continent=America;; + *" "*) continent=`expr "$continent" : '\''\([^ ]*\)'\''` + esac ' esac case $continent in - '') - exit 1;; TZ) # Ask the user for a Posix TZ string. Check that it conforms. while @@ -265,39 +324,35 @@ while '74 degrees 3 minutes west.' read coord;; esac - distance_table=$($AWK \ + distance_table=`$AWK \ -v coord="$coord" \ -v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \ "$output_distances" <$TZ_ZONE_TABLE | sort -n | sed "${location_limit}q" - ) - regions=$(echo "$distance_table" | $AWK ' + ` + regions=`echo "$distance_table" | $AWK ' BEGIN { FS = "\t" } { print $NF } - ') + '` echo >&2 'Please select one of the following' \ 'time zone regions,' echo >&2 'listed roughly in increasing order' \ "of distance from $coord". - select region in $regions - do - case $region in - '') echo >&2 'Please enter a number in range.';; - ?*) break;; - esac - done - TZ=$(echo "$distance_table" | $AWK -v region="$region" ' + doselect $regions + region=$select_result + TZ=`echo "$distance_table" | $AWK -v region="$region" ' BEGIN { FS="\t" } $NF == region { print $4 } - ') + '` ;; *) # Get list of names of countries in the continent or ocean. - countries=$($AWK -F'\t' \ + countries=`$AWK \ -v continent="$continent" \ -v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \ ' + BEGIN { FS = "\t" } /^#/ { next } $3 ~ ("^" continent "/") { if (!cc_seen[$1]++) cc_list[++ccs] = $1 @@ -314,7 +369,7 @@ while print country } } - ' <$TZ_ZONE_TABLE | sort -f) + ' <$TZ_ZONE_TABLE | sort -f` # If there's more than one country, ask the user which one. @@ -322,28 +377,20 @@ while *"$newline"*) echo >&2 'Please select a country' \ 'whose clocks agree with yours.' - select country in $countries - do - case $country in - '') echo >&2 'Please enter a number in range.';; - ?*) break - esac - done - - case $country in - '') exit 1 - esac;; + doselect $countries + country=$select_result;; *) country=$countries esac # Get list of names of time zone rule regions in the country. - regions=$($AWK -F'\t' \ + regions=`$AWK \ -v country="$country" \ -v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \ ' BEGIN { + FS = "\t" cc = country while (getline <TZ_COUNTRY_TABLE) { if ($0 !~ /^#/ && country == $2) { @@ -353,7 +400,7 @@ while } } $1 == cc { print $4 } - ' <$TZ_ZONE_TABLE) + ' <$TZ_ZONE_TABLE` # If there's more than one region, ask the user which one. @@ -361,27 +408,20 @@ while *"$newline"*) echo >&2 'Please select one of the following' \ 'time zone regions.' - select region in $regions - do - case $region in - '') echo >&2 'Please enter a number in range.';; - ?*) break - esac - done - case $region in - '') exit 1 - esac;; + doselect $regions + region=$select_result;; *) region=$regions esac # Determine TZ from country and region. - TZ=$($AWK -F'\t' \ + TZ=`$AWK \ -v country="$country" \ -v region="$region" \ -v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \ ' BEGIN { + FS = "\t" cc = country while (getline <TZ_COUNTRY_TABLE) { if ($0 !~ /^#/ && country == $2) { @@ -391,7 +431,7 @@ while } } $1 == cc && $4 == region { print $3 } - ' <$TZ_ZONE_TABLE) + ' <$TZ_ZONE_TABLE` esac # Make sure the corresponding zoneinfo file exists. @@ -410,10 +450,10 @@ while extra_info= for i in 1 2 3 4 5 6 7 8 do - TZdate=$(LANG=C TZ="$TZ_for_date" date) - UTdate=$(LANG=C TZ=UTC0 date) - TZsec=$(expr "$TZdate" : '.*:\([0-5][0-9]\)') - UTsec=$(expr "$UTdate" : '.*:\([0-5][0-9]\)') + TZdate=`LANG=C TZ="$TZ_for_date" date` + UTdate=`LANG=C TZ=UTC0 date` + TZsec=`expr "$TZdate" : '.*:\([0-5][0-9]\)'` + UTsec=`expr "$UTdate" : '.*:\([0-5][0-9]\)'` case $TZsec in $UTsec) extra_info=" @@ -440,16 +480,9 @@ Universal Time is now: $UTdate." echo >&2 "Therefore TZ='$TZ' will be used.$extra_info" echo >&2 "Is the above information OK?" - ok= - select ok in Yes No - do - case $ok in - '') echo >&2 'Please enter 1 for Yes, or 2 for No.';; - ?*) break - esac - done + doselect Yes No + ok=$select_result case $ok in - '') exit 1;; Yes) break esac do coord= diff --git a/elsie.nci.nih.gov/src/zdump.c b/elsie.nci.nih.gov/src/zdump.c index 2a9860c..209b79d 100644 --- a/elsie.nci.nih.gov/src/zdump.c +++ b/elsie.nci.nih.gov/src/zdump.c @@ -59,6 +59,7 @@ typedef int int_fast32_t; #ifndef INTMAX_MAX # if defined LLONG_MAX || defined __LONG_LONG_MAX__ typedef long long intmax_t; +# define strtoimax strtoll # define PRIdMAX "lld" # ifdef LLONG_MAX # define INTMAX_MAX LLONG_MAX @@ -67,13 +68,11 @@ typedef long long intmax_t; # endif # else typedef long intmax_t; +# define strtoimax strtol # define PRIdMAX "ld" # define INTMAX_MAX LONG_MAX # endif #endif -#ifndef SCNdMAX -# define SCNdMAX PRIdMAX -#endif #ifndef ZDUMP_LO_YEAR @@ -368,16 +367,19 @@ main(int argc, char *argv[]) if (vflag | Vflag) { intmax_t lo; intmax_t hi; - char dummy; + char *loend, *hiend; register intmax_t cutloyear = ZDUMP_LO_YEAR; register intmax_t cuthiyear = ZDUMP_HI_YEAR; if (cutarg != NULL) { - if (sscanf(cutarg, "%"SCNdMAX"%c", &hi, &dummy) == 1) { + lo = strtoimax(cutarg, &loend, 10); + if (cutarg != loend && !*loend) { + hi = lo; + cuthiyear = hi; + } else if (cutarg != loend && *loend == ',' + && (hi = strtoimax(loend + 1, &hiend, 10), + loend + 1 != hiend && !*hiend)) { + cutloyear = lo; cuthiyear = hi; - } else if (sscanf(cutarg, "%"SCNdMAX",%"SCNdMAX"%c", - &lo, &hi, &dummy) == 2) { - cutloyear = lo; - cuthiyear = hi; } else { (void) fprintf(stderr, _("%s: wild -c argument %s\n"), progname, cutarg); @@ -389,14 +391,17 @@ main(int argc, char *argv[]) cuthitime = yeartot(cuthiyear); } if (cuttimes != NULL) { - if (sscanf(cuttimes, "%"SCNdMAX"%c", &hi, &dummy) == 1) { + lo = strtoimax(cuttimes, &loend, 10); + if (cuttimes != loend && !*loend) { + hi = lo; if (hi < cuthitime) { if (hi < absolute_min_time) hi = absolute_min_time; cuthitime = hi; } - } else if (sscanf(cuttimes, "%"SCNdMAX",%"SCNdMAX"%c", - &lo, &hi, &dummy) == 2) { + } else if (cuttimes != loend && *loend == ',' + && (hi = strtoimax(loend + 1, &hiend, 10), + loend + 1 != hiend && !*hiend)) { if (cutlotime < lo) { if (absolute_max_time < lo) lo = absolute_max_time; |