1
0
mirror of https://frontier.innolan.net/rainlance/amiga-tz.git synced 2025-11-24 00:48:41 +00:00

Add -t ZONETABTYPE option to 'tzselect'.

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.
This commit is contained in:
Paul Eggert
2013-08-16 12:19:42 -07:00
parent d58b59dd8a
commit cc3f93886b
6 changed files with 148 additions and 20 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
*~
ChangeLog
leapseconds
time.tab
tzselect
version.h
yearistype

View File

@ -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 $@

View File

@ -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

View File

@ -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 || {

34
zone-time.awk Normal file
View File

@ -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
}
}

View File

@ -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.