[PATCH 1/3] Further removal of attempt to support floating-point time_t.
* localtime.c (timesub): * zdump.c (my_localtime): Don't worry about time_t being floating-point. * localtime.c (timesub): Avoid undefined behavior on integer overflow when assigning time_t to int. --- localtime.c | 5 +++-- zdump.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/localtime.c b/localtime.c index 5312ad9..f58b20a 100644 --- a/localtime.c +++ b/localtime.c @@ -1489,9 +1489,10 @@ timesub(const time_t *const timep, const int_fast32_t offset, register int leapdays; tdelta = tdays / DAYSPERLYEAR; - idelta = tdelta; - if (tdelta - idelta >= 1 || idelta - tdelta >= 1) + if (! ((! TYPE_SIGNED(time_t) || INT_MIN <= tdelta) + && tdelta <= INT_MAX)) return NULL; + idelta = tdelta; if (idelta == 0) idelta = (tdays < 0) ? -1 : 1; newy = y; diff --git a/zdump.c b/zdump.c index 36c1838..fa5f8d8 100644 --- a/zdump.c +++ b/zdump.c @@ -244,7 +244,7 @@ my_localtime(time_t *tp) tm = *tmp; t = mktime(&tm); - if (t - *tp >= 1 || *tp - t >= 1) { + if (t != *tp) { (void) fflush(stdout); (void) fprintf(stderr, "\n%s: ", progname); (void) fprintf(stderr, tformat(), *tp); -- 1.8.1.2
This unnecessary duplicate of America/Denver was confusing, as it incorrectly implied that 'Mountain Time - Navajo' differed from 'Mountain Time' either now or in the past. Clarify this in a better way, by mentioning in the Arizona entry that it doesn't include Navajo. --- zone.tab | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zone.tab b/zone.tab index 73cabf6..86a9095 100644 --- a/zone.tab +++ b/zone.tab @@ -423,8 +423,7 @@ US +465042-1012439 America/North_Dakota/New_Salem Central Time - North Dakota - US +471551-1014640 America/North_Dakota/Beulah Central Time - North Dakota - Mercer County US +394421-1045903 America/Denver Mountain Time US +433649-1161209 America/Boise Mountain Time - south Idaho & east Oregon -US +364708-1084111 America/Shiprock Mountain Time - Navajo -US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona +US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona (except Navajo) US +340308-1181434 America/Los_Angeles Pacific Time US +611305-1495401 America/Anchorage Alaska Time US +581807-1342511 America/Juneau Alaska Time - Alaska panhandle -- 1.8.1.2
On Fri, 16 Aug 2013, Paul Eggert wrote:
This unnecessary duplicate of America/Denver was confusing, as it incorrectly implied that 'Mountain Time - Navajo' differed from 'Mountain Time' either now or in the past. Clarify this in a better way, by mentioning in the Arizona entry that it doesn't include Navajo.
But doesn't this also remove the link between "US" and "America/Shiprock"?
--- zone.tab | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/zone.tab b/zone.tab index 73cabf6..86a9095 100644 --- a/zone.tab +++ b/zone.tab @@ -423,8 +423,7 @@ US +465042-1012439 America/North_Dakota/New_Salem Central Time - North Dakota - US +471551-1014640 America/North_Dakota/Beulah Central Time - North Dakota - Mercer County US +394421-1045903 America/Denver Mountain Time US +433649-1161209 America/Boise Mountain Time - south Idaho & east Oregon -US +364708-1084111 America/Shiprock Mountain Time - Navajo -US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona +US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona (except Navajo) US +340308-1181434 America/Los_Angeles Pacific Time US +611305-1495401 America/Anchorage Alaska Time US +581807-1342511 America/Juneau Alaska Time - Alaska panhandle
-- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug Posted with an email client that doesn't mangle email: alpine
Derick Rethans wrote:
doesn't this also remove the link between "US" and "America/Shiprock"?
No, "US/Mountain" and "America/Shiprock" will continue to be links to "America/Denver", which means they'll continue to be links to each other.
Derick didn't mention US/Mountain; I'm pretty sure he was referring to the country/region code US. I believe he is saying that removing this entry from zone.tab undoes the mapping between the America/Shiprock alias and the US country code. I was initially concerned by this change as well, but as it seems that other aliases listed in backward do not appear in zone.tab, I don't think it's an issue. I think it's safe to say that aliases are presumed to be part of the same country/region that their linked zone is part of. (All the more reason NOT to alias across country borders, if you ask me...) -- Tim Parenti On 19 August 2013 16:38, Paul Eggert <eggert@cs.ucla.edu> wrote:
Derick Rethans wrote:
doesn't this also remove the link between "US" and "America/Shiprock"?
No, "US/Mountain" and "America/Shiprock" will continue to be links to "America/Denver", which means they'll continue to be links to each other.
On Mon, 19 Aug 2013, Tim Parenti wrote:
Derick didn't mention US/Mountain; I'm pretty sure he was referring to the country/region code US. I believe he is saying that removing this entry from zone.tab undoes the mapping between the America/Shiprock alias and the US country code.
That is indeed what I meant. cheers, Derick
This is a backwards-compatible way of transitioning to a less politically-charged approach to choosing TZ values. A new time zone table time.tab acts like zone.tab, except it omits TZ values that are present only for political reasons. tzselect has a new "-t zonetabtype" option that lets users select which time zone table to use, and installers can select the default table. The zone.tab file does not change, and the default tzselect table for now is zone.tab. This avoids the backward-compatibility concerns expressed on the tz mailing list; see, for example, the discussion surrounding Derick Rethans's comments in <http://mm.icann.org/pipermail/tz/2013-August/019544.html> * .gitignore: Add time.tab. * Makefile (ZONETABTYPE): New macro. (TABDATA): Add time.tab. (all): Depend on $(TABDATA). (install): Do not depend on $(TABDATA), since $(DATA) includes it. Install time.tab too. (time.tab): New rule. (tzselect.tab): Substitute ZONETABTYPE. * zone-time.awk: New file. * tzselect.8: Document new options, and --help and --version while we're at it. * tzselect.ksh (ZONETABTYPE): New var. Implement -t ZONETABTYPE option. Check that no extra operands are given. * zone.tab: Change first comment line, to distinguish the two tables better. --- .gitignore | 1 + Makefile | 23 +++++++++++++++----- tzselect.8 | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- tzselect.ksh | 40 +++++++++++++++++++++++------------ zone-time.awk | 34 ++++++++++++++++++++++++++++++ zone.tab | 2 +- 6 files changed, 148 insertions(+), 20 deletions(-) create mode 100644 zone-time.awk diff --git a/.gitignore b/.gitignore index 21c798d..5759d2a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *~ ChangeLog leapseconds +time.tab tzselect version.h yearistype diff --git a/Makefile b/Makefile index 68d7132..a74d1a7 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,15 @@ LOCALTIME= GMT POSIXRULES= America/New_York +# Default time zone table type for 'tzselect'. See tzselect.8 for details. +# Possible values are: +# 'time' - for a smaller time zone table +# 'zone' - for a backward compatible time zone table; it contains +# alternative TZ values present for compatibility with older versions of +# this software. + +ZONETABTYPE= zone + # Also see TZDEFRULESTRING below, which takes effect only # if the time zone files cannot be accessed. @@ -317,7 +326,7 @@ 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 time.tab zone.tab DATA= $(YDATA) $(NDATA) $(SDATA) $(TABDATA) \ leap-seconds.list yearistype.sh WEB_PAGES= tz-art.htm tz-link.htm @@ -331,15 +340,15 @@ ENCHILADA= $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) SHELL= /bin/sh -all: tzselect zic zdump $(LIBOBJS) +all: tzselect zic zdump $(LIBOBJS) $(TABDATA) ALL: all date -install: all $(DATA) $(REDO) $(TZLIB) $(MANS) $(TABDATA) +install: all $(DATA) $(REDO) $(TZLIB) $(MANS) $(ZIC) -y $(YEARISTYPE) \ -d $(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES) - -rm -f $(TZDIR)/iso3166.tab $(TZDIR)/zone.tab - cp iso3166.tab zone.tab $(TZDIR)/. + -rm -f $(TZDIR)/iso3166.tab $(TZDIR)/time.tab $(TZDIR)/zone.tab + cp iso3166.tab time.tab zone.tab $(TZDIR)/. -mkdir $(TOPDIR) $(ETCDIR) cp tzselect zic zdump $(ETCDIR)/. -mkdir $(TOPDIR) $(MANDIR) \ @@ -411,6 +420,9 @@ posix_right: posix_only leapseconds zones: $(REDO) +time.tab: $(YDATA) zone.tab zone-time.awk + $(AWK) -f zone-time.awk $(YDATA) >$@ + $(TZLIB): $(LIBOBJS) -mkdir $(TOPDIR) $(LIBDIR) ar ru $@ $(LIBOBJS) @@ -428,6 +440,7 @@ tzselect: tzselect.ksh -e 's|\(REPORT_BUGS_TO\)=.*|\1=$(BUGEMAIL)|' \ -e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \ -e 's|\(TZVERSION\)=.*|\1=$(VERSION)|' \ + -e 's|^\(ZONETABTYPE\)=.*|\1=$(ZONETABTYPE)|' \ <$? >$@ chmod +x $@ diff --git a/tzselect.8 b/tzselect.8 index 0d02590..b5e2c88 100644 --- a/tzselect.8 +++ b/tzselect.8 @@ -3,6 +3,14 @@ tzselect \- select a time zone .SH SYNOPSIS .B tzselect +[ +.B \-t +.I zonetabtype +] [ +.B \-\-help +] [ +.B \-\-version +] .SH DESCRIPTION The .B tzselect @@ -11,6 +19,62 @@ and outputs the resulting time zone description to standard output. The output is suitable as a value for the TZ environment variable. .PP All interaction with the user is done via standard input and standard error. +.SH OPTIONS +.TP +.BI "\-t " zonetabtype +Make selections from the time zone table of type +.IR zonetabtype . +Possible +.I zonetabtype +values include: +.RS +.TP +.B time +A time zone table with a smaller set of zone names. +.TP +.B zone +A time zone table that also contains alternative zone names, for +backward compatibility with older versions of this software. The +alternative names are not needed for proper operation of time stamps; +they are present only to avoid surprises with people who are +accustomed to the old names. These alternative names arose from +political issues that are outside the scope of +.BR tzselect . +.PP +For example, both tables have entries for countries like +Bosnia, Croatia, and Serbia, which are in a zone where the clocks +have all agreed since 1970. Although the +.B time +table lists "Europe/Belgrade" for this zone wherever it occurs, the +.B zone +table instead lists the names "Europe/Sarajevo", "Europe/Zagreb", +etc. under Bosnia, Croatia, etc. This means that the +.B "\-t\ time" +option causes +.B tzselect +to generate "Europe/Belgrade" for this zone, whereas +.B "\-t\ zone" +causes it to generate different names depending on the country, +names that are equivalent in effect to "Europe/Belgrade". +.PP +The default +.I zonetabtype +is system-dependent, so applications that care about the set of +names that +.B tzselect +generates should use the +.B "\-t" +option. Regardless of what options are used, applications should not +assume that +.BR tzselect 's +output matches the user's political preferences. +.RE +.TP +.B "\-\-help" +Output help information and exit. +.TP +.B "\-\-version" +Output version information and exit. .SH "ENVIRONMENT VARIABLES" .TP \f3AWK\fP @@ -27,8 +91,10 @@ Name of the directory containing time zone data files (default: \f2TZDIR\fP\f3/iso3166.tab\fP Table of ISO 3166 2-letter country codes and country names. .TP +\f2TZDIR\fP\f3/time.tab\fP +.TP \f2TZDIR\fP\f3/zone.tab\fP -Table of country codes, latitude and longitude, TZ values, and +Tables of country codes, latitude and longitude, zone names, and descriptive comments. .TP \f2TZDIR\fP\f3/\fP\f2TZ\fP diff --git a/tzselect.ksh b/tzselect.ksh index 8e66b44..dc9f256 100644 --- a/tzselect.ksh +++ b/tzselect.ksh @@ -3,6 +3,7 @@ PKGVERSION='(tzcode) ' TZVERSION=see_Makefile REPORT_BUGS_TO=tz@iana.org +ZONETABTYPE=zone # Ask the user about the time zone, and output the resulting TZ value to stdout. # Interact with the user via stderr and stdin. @@ -40,24 +41,37 @@ REPORT_BUGS_TO=tz@iana.org exit 1 } -if [ "$1" = "--help" ]; then - cat <<EOF -Usage: tzselect +usage="Usage: tzselect [--version] [--help] [-t ZONETABTYPE] Select a time zone interactively. +ZONETABTYPE should be one of 'time' or 'zone'. -Report bugs to $REPORT_BUGS_TO. -EOF - exit -elif [ "$1" = "--version" ]; then - cat <<EOF -tzselect $PKGVERSION$TZVERSION -EOF - exit -fi +Report bugs to $REPORT_BUGS_TO." + +while getopts t:-: opt +do + case $opt$OPTARG in + t*) + ZONETABTYPE=$OPTARG ;; + -help) + exec echo "$usage" ;; + -version) + exec echo "tzselect $PKGVERSION$TZVERSION" ;; + -*) + echo >&2 "$0: -$opt$OPTARG: unknown option; try '$0 --help'"; exit 1 ;; + *) + echo >&2 "$0: try '$0 --help'"; exit 1 ;; + esac +done + +shift $((OPTIND-1)) +case $# in +0) ;; +*) echo >&2 "$0: $1: unknown argument"; exit 1 ;; +esac # Make sure the tables are readable. TZ_COUNTRY_TABLE=$TZDIR/iso3166.tab -TZ_ZONE_TABLE=$TZDIR/zone.tab +TZ_ZONE_TABLE=$TZDIR/$ZONETABTYPE.tab for f in $TZ_COUNTRY_TABLE $TZ_ZONE_TABLE do <$f || { diff --git a/zone-time.awk b/zone-time.awk new file mode 100644 index 0000000..5210c1f --- /dev/null +++ b/zone-time.awk @@ -0,0 +1,34 @@ +# Generate 'time.tab' from 'zone.tab'. Standard input should be the zic input. + +# This file is in the public domain. + +# Contributed by Paul Eggert. + +$1 == "Link" { link[$3] = $2 } + +END { + FS = "\t" + while (getline < "zone.tab") { + line = $0 + if (line ~ /^# TZ zone descriptions/) + line = "# TZ zone descriptions, with a smaller set of zone names" + if (line ~ /^# 4. Comments;/) { + print "# Zones can cross country-code boundaries, so the" + print "# location named by column 3 need not lie in the" + print "# locations identified by columns 1 or 2." + } + if (line ~ /^[^#]/) { + code = $1 + target = $3 + while (link[target]) + target = link[target] + if (already_seen[code, target]) + continue + already_seen[code, target] = 1 + line = code "\t" $2 "\t" target + if ($4) + line = line "\t" $4 + } + print line + } +} diff --git a/zone.tab b/zone.tab index 86a9095..0ebbb0c 100644 --- a/zone.tab +++ b/zone.tab @@ -1,4 +1,4 @@ -# TZ zone descriptions +# TZ zone descriptions, with alternative zone names for backward compatiblity # # This file is in the public domain, so clarified as of # 2009-05-17 by Arthur David Olson. -- 1.8.1.2
--- zone.tab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone.tab b/zone.tab index 0ebbb0c..b4407f1 100644 --- a/zone.tab +++ b/zone.tab @@ -1,4 +1,4 @@ -# TZ zone descriptions, with alternative zone names for backward compatiblity +# TZ zone descriptions, with alternative zone names for backward compatibility # # This file is in the public domain, so clarified as of # 2009-05-17 by Arthur David Olson. -- 1.8.1.2
participants (3)
-
Derick Rethans -
Paul Eggert -
Tim Parenti