update from tzcode 2013e to tzcode2013i

i:
    The compile-time flag NOSOLAR has been removed, as nowadays the
    benefit of slightly shrinking runtime table size is outweighed by the
    cost of disallowing potential future updates that exceed old limits.
h:
    Fix localtime overflow bugs with 32-bit unsigned time_t.

    zdump no longer assumes sscanf returns maximal values on overflow.
g:
    'zic' now runs on platforms that lack both hard links and symlinks.
    (Thanks to Theo Veenker for reporting the problem, for MinGW.)
    Also, fix some bugs on platforms that lack hard links but have symlinks.

    'zic -v' again warns that Asia/Tehran has no POSIX environment variable
    to predict the far future, fixing a bug introduced in 2013e.
f:
    The types of the global variables 'timezone' and 'altzone' (if present)
    have been changed back to 'long'.  This is required for 'timezone'
    by POSIX, and for 'altzone' by common practice, e.g., Solaris 11.
    These variables were originally 'long' in the tz code, but were
    mistakenly changed to 'time_t' in 1987; nobody reported the
    incompatibility until now.  The difference matters on x32, where
    'long' is 32 bits and 'time_t' is 64.  (Thanks to Elliott Hughes.)
This commit is contained in:
christos 2013-12-26 18:34:28 +00:00
parent 6a278d918a
commit 002951760f
14 changed files with 2893 additions and 466 deletions

View File

@ -6,7 +6,7 @@
PACKAGE= tzcode
# Version numbers of the code and data distributions.
VERSION= 2013e
VERSION= 2013i
# 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
@ -107,6 +106,7 @@ LDLIBS=
# -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares
# ctime_r and asctime_r incompatibly with the POSIX standard (Solaris 8).
# -DHAVE_INTTYPES_H=1 if you have a pre-C99 compiler with "inttypes.h"
# -DHAVE_LINK=0 if your system lacks a link function
# -DHAVE_SETTIMEOFDAY=0 if settimeofday does not exist (SVR0?)
# -DHAVE_SETTIMEOFDAY=1 if settimeofday has just 1 arg (SVR4)
# -DHAVE_SETTIMEOFDAY=2 if settimeofday uses 2nd arg (4.3BSD)
@ -197,14 +197,6 @@ GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \
# These functions may well disappear in future releases of the time
# conversion package.
#
# If you'll never want to handle solar-time-based time zones, add
# -DNOSOLAR
# to the end of the "CFLAGS=" line
# (and comment out the "SDATA=" line below).
# This reduces (slightly) the run-time data-space requirements of
# the time conversion functions; it may reduce the acceptability of your system
# to folks in oil- and cash-rich places.
#
# If you want to allocate state structures in localtime, add
# -DALL_STATE
# to the end of the "CFLAGS=" line. Storage is obtained by calling malloc.
@ -247,8 +239,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 +294,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
TZDOBJS= zdump.o localtime.o ialloc.o
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
@ -312,17 +310,21 @@ NEWUCBSRCS= date.c strftime.c
SOURCES= $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) tzselect.ksh
MANS= newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
tzfile.5 tzselect.8 zic.8 zdump.8
COMMON= Makefile
DOCS= README Theory $(MANS) date.1
MANTXTS= newctime.3.txt newstrftime.3.txt newtzset.3.txt \
time2posix.3.txt \
tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \
date.1.txt
COMMON= Makefile README
DOCS= NEWS Theory $(MANS) date.1 $(MANTXTS)
PRIMARY_YDATA= africa antarctica asia australasia \
europe northamerica southamerica
YDATA= $(PRIMARY_YDATA) pacificnew etcetera backward
NDATA= systemv factory
SDATA= solar87 solar88 solar89
TDATA= $(YDATA) $(NDATA) $(SDATA)
TABDATA= iso3166.tab zone.tab
DATA= $(YDATA) $(NDATA) $(SDATA) $(TABDATA) \
leap-seconds.list yearistype.sh
TDATA= $(YDATA) $(NDATA)
TABDATA= iso3166.tab zone.tab leapseconds
LEAP_DEPS= leapseconds.awk leap-seconds.list
DATA= $(YDATA) $(NDATA) $(TABDATA) \
$(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 \
@ -335,38 +337,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)
$(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 tzselect zic zdump $(DESTDIR)$(ETCDIR)/.
-mkdir $(DESTDIR)$(TOPDIR) $(DESTDIR)$(MANDIR) \
install: all $(DATA) $(REDO) $(MANS)
mkdir -p $(DESTDIR)$(ETCDIR) $(DESTDIR)$(TZDIR) \
$(DESTDIR)$(LIBDIR) \
$(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/.
$(ZIC) -y $(YEARISTYPE) \
-d $(DESTDIR)$(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
cp -f iso3166.tab zone.tab $(DESTDIR)$(TZDIR)/.
cp tzselect zic zdump $(DESTDIR)$(ETCDIR)/.
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)) ";' && \
@ -383,7 +376,7 @@ yearistype: yearistype.sh
cp yearistype.sh yearistype
chmod +x yearistype
leapseconds: leapseconds.awk leap-seconds.list
leapseconds: $(LEAP_DEPS)
$(AWK) -f leapseconds.awk leap-seconds.list >$@
posix_only: zic $(TDATA)
@ -421,11 +414,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)
@ -454,57 +445,81 @@ 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 *.[1-8].txt *.asc *.tar.gz
rm -f leapseconds $(MANTXTS) *.asc *.tar.gz
names:
@echo $(ENCHILADA)
public: check check_public check_time_t_alternatives \
set-timestamps tarballs signatures
tarballs signatures
date.1.txt: date.1
newctime.3.txt: newctime.3
newstrftime.3.txt: newstrftime.3
newtzset.3.txt: newtzset.3
time2posix.3.txt: time2posix.3
tzfile.5.txt: tzfile.5
tzselect.8.txt: tzselect.8
zdump.8.txt: zdump.8
zic.8.txt: zic.8
$(MANTXTS): workman.sh
LC_ALL=C sh workman.sh `expr $@ : '\(.*\)\.txt$$'` >$@
# Set the time stamps to those of the git repository, if available,
# 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.
set-timestamps:
-TZ=UTC0 && export TZ && files=`git ls-files` && \
touch -d @1 test.out && rm -f test.out && \
for file in $$files; do \
test -z "`git diff --name-only $$file`" || continue; \
cmd="touch -d @`git log -1 --format='format:%ct' $$file \
` $$file" && \
echo "$$cmd" && \
$$cmd || exit; \
# 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 $@
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 || \
exit; \
done
touch $@
# The zics below ensure that each data file can stand on its own.
# We also do an all-files run to catch links to links.
check_public: $(ENCHILADA)
make maintainer-clean
make "CFLAGS=$(GCC_DEBUG_FLAGS)"
make "CFLAGS=$(GCC_DEBUG_FLAGS)" $(ENCHILADA) all
mkdir tzpublic
for i in $(TDATA) ; do \
$(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'" \
@ -525,21 +540,17 @@ 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
tzcode$(VERSION).tar.gz: $(COMMON) $(DOCS) $(SOURCES) $(MISC)
for i in *.[1-8] ; do \
LC_ALL=C sh workman.sh $$i > $$i.txt && \
touch -r $$i $$i.txt || exit; \
done
tzcode$(VERSION).tar.gz: set-timestamps.out
LC_ALL=C && export LC_ALL && \
tar $(TARFLAGS) -cf - \
$(COMMON) $(DOCS) $(SOURCES) $(MISC) *.[1-8].txt | \
$(COMMON) $(DOCS) $(SOURCES) $(MISC) | \
gzip $(GZIPFLAGS) > $@
tzdata$(VERSION).tar.gz: $(COMMON) $(DATA)
tzdata$(VERSION).tar.gz: set-timestamps.out
LC_ALL=C && export LC_ALL && \
tar $(TARFLAGS) -cf - $(COMMON) $(DATA) | \
gzip $(GZIPFLAGS) > $@

2279
lib/libc/time/NEWS Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,18 @@
README for the tz distribution
This file is in the public domain, so clarified as of
2009-05-17 by Arthur David Olson.
"What time is it?" -- Richard Deacon as The King
"Any time you want it to be." -- Frank Baxter as The Scientist
(from the Bell System film "About Time")
The 1989 update of the time zone package featured
The Time Zone Database (often called tz or zoneinfo) contains code and
data that represent the history of local time for many representative
locations around the globe. It is updated periodically to reflect
changes made by political bodies to time zone boundaries, UTC offsets,
and daylight-saving rules.
* POSIXization (including interpretation of POSIX-style TZ environment
variables, provided by Guy Harris),
* ANSIfication (including versions of "mktime" and "difftime"),
* SVIDulation (an "altzone" variable)
* MACHination (the "gtime" function)
* corrections to some time zone data (including corrections to the rules
for Great Britain and New Zealand)
* reference data from the United States Naval Observatory for folks who
want to do additional time zones
* and the 1989 data for Saudi Arabia.
(Since this code will be treated as "part of the implementation" in some places
and as "part of the application" in others, there's no good way to name
functions, such as timegm, that are not part of the proposed ANSI C standard;
such functions have kept their old, underscore-free names in this update.)
And the "dysize" function has disappeared; it was present to allow compilation
of the "date" command on old BSD systems, and a version of "date" is now
provided in the package. The "date" command is not created when you "make all"
since it may lack options provided by the version distributed with your
operating system, or may not interact with the system in the same way the
native version does.
Since POSIX frowns on correct leap second handling, the default behavior of
the "zic" command (in the absence of a "-L" option) has been changed to omit
leap second information from its output files.
Unless otherwise specified, all files in the tz code and data are in
the public domain, so clarified as of 2009-05-17 by Arthur David Olson.
The few exceptions are code derived from BSD, which uses the BSD license.
Here is a recipe for acquiring, building, installing, and testing the
tz distribution on a GNU/Linux or similar host.
@ -53,8 +31,6 @@ substituting your desired installation directory for "$HOME/tzdir":
make TOPDIR=$HOME/tzdir install
$HOME/tzdir/etc/zdump -v America/Los_Angeles
To use the new functions, use a "-ltz" option when compiling or linking.
Historical local time information has been included here to:
* provide a compendium of data about the history of civil time
@ -71,7 +47,7 @@ The information in the time zone data files is by no means authoritative;
the files currently do not even attempt to cover all time stamps before
1970, and there are undoubtedly errors even for time stamps since 1970.
If you know that the rules are different from those in a file, by all means
feel free to change file (and please send the changed version to
feel free to change a file (and please send the changed version to
tz@iana.org for use in the future). Europeans take note!
Thanks to these Timezone Caballeros who've made major contributions to the
@ -79,15 +55,10 @@ time conversion package: Keith Bostic; Bob Devine; Paul Eggert; Robert Elz;
Guy Harris; Mark Horton; John Mackin; and Bradley White. Thanks also to
Michael Bloom, Art Neilson, Stephen Prince, John Sovereign, and Frank Wales
for testing work, and to Gwillim Law for checking local mean time data.
Thanks in particular to Arthur David Olson, the project's founder and first
maintainer, to whom the timezone community owes the greatest debt of all.
None of them are responsible for remaining errors.
Look in <ftp://ftp.iana.org/tz/releases/>
for updated versions of these files.
Look in <ftp://ftp.iana.org/tz/releases/> for updated versions of these files.
Please send comments or information to tz@iana.org.
Postscript: The README above is largely unmodified (aside from details
of mailing list and ftp archive addresses) from that prepared many years
ago by Arthur David Olson, to whom the timezone community owes the
greatest debt of all. Arthur is not currently maintaining this data or
code (though he remains involved).

View File

@ -1,8 +1,8 @@
.\" $NetBSD: ctime.3,v 1.48 2013/09/20 19:06:54 christos Exp $
.\" $NetBSD: ctime.3,v 1.49 2013/12/26 18:34:28 christos Exp $
.\"
.\" XXX: License missing?
.\"
.Dd September 20, 2013
.Dd December 26, 2013
.Dt CTIME 3
.Os
.Sh NAME
@ -551,10 +551,6 @@ restricted to years in the range 1900 through 2099.
To avoid this portability mess, new programs should use
.Fn strftime
instead.
.Pp
Avoid using out-of-range values with
.Fn mktime
when setting up lunch with promptness sticklers in Riyadh.
.\" @(#)newctime.3 8.3
.\" This file is in the public domain, so clarified as of
.\" 2009-05-17 by Arthur David Olson.

View File

@ -0,0 +1,66 @@
# Generate the 'leapseconds' file from 'leap-seconds.list'.
# This file is in the public domain.
BEGIN {
print "# Allowance for leapseconds added to each timezone file."
print ""
print "# This file is in the public domain."
print ""
print "# This file is generated automatically from the data in the public-domain"
print "# leap-seconds.list file available from most NIST time servers."
print "# If the URL <ftp://time.nist.gov/pub/leap-seconds.list> does not work,"
print "# you should be able to pick up leap-seconds.list from a secondary NIST server."
print "# For more about leap-seconds.list, please see"
print "# The NTP Timescale and Leap Seconds"
print "# <http://www.eecis.udel.edu/~mills/leap.html>."
print ""
print "# The International Earth Rotation Service periodically uses leap seconds"
print "# to keep UTC to within 0.9 s of UT1"
print "# (which measures the true angular orientation of the earth in space); see"
print "# Terry J Quinn, The BIPM and the accurate measure of time,"
print "# Proc IEEE 79, 7 (July 1991), 894-905 <http://dx.doi.org/10.1109/5.84965>."
print "# There were no leap seconds before 1972, because the official mechanism"
print "# accounting for the discrepancy between atomic time and the earth's rotation"
print "# did not exist until the early 1970s."
print ""
print "# The correction (+ or -) is made at the given time, so lines"
print "# will typically look like:"
print "# Leap YEAR MON DAY 23:59:60 + R/S"
print "# or"
print "# Leap YEAR MON DAY 23:59:59 - R/S"
print ""
print "# If the leapsecond is Rolling (R) the given time is local time."
print "# If the leapsecond is Stationary (S) the given time is UTC."
print ""
print "# Leap YEAR MONTH DAY HH:MM:SS CORR R/S"
}
/^ *$/ { next }
/^#/ { next }
{
NTP_timestamp = $1
TAI_minus_UTC = $2
hash_mark = $3
one = $4
month = $5
year = $6
if (old_TAI_minus_UTC) {
if (old_TAI_minus_UTC < TAI_minus_UTC) {
sign = "23:59:60\t+"
} else {
sign = "23:59:59\t-"
}
if (month == "Jan") {
year--;
month = "Dec";
day = 31
} else if (month == "Jul") {
month = "Jun";
day = 30
}
printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign
}
old_TAI_minus_UTC = TAI_minus_UTC
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: localtime.c,v 1.80 2013/12/13 10:37:24 christos Exp $ */
/* $NetBSD: localtime.c,v 1.81 2013/12/26 18:34:28 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.17";
#else
__RCSID("$NetBSD: localtime.c,v 1.80 2013/12/13 10:37:24 christos Exp $");
__RCSID("$NetBSD: localtime.c,v 1.81 2013/12/26 18:34:28 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -163,7 +163,7 @@ typedef struct tm *(*subfun_t)(const timezone_t sp, const time_t *timep,
*/
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) ATTRIBUTE_PURE;
@ -179,6 +179,7 @@ static struct tm * localsub(const timezone_t sp, const time_t *timep,
const int_fast32_t offset, struct tm *tmp);
static int increment_overflow(int * number, int delta);
static int increment_overflow32(int_fast32_t * number, int delta);
static int increment_overflow_time(time_t *t, int_fast32_t delta);
static int leaps_thru_end_of(int y) ATTRIBUTE_PURE;
static int normalize_overflow(int * tensptr, int * unitsptr,
int base);
@ -197,9 +198,9 @@ static struct tm * timesub(const timezone_t sp, const time_t * timep,
const int_fast32_t offset, 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,
const int_fast32_t offset) ATTRIBUTE_PURE;
static int_fast32_t transtime(int year, const struct rule * rulep,
int_fast32_t offset)
ATTRIBUTE_PURE;
static int typesequiv(const timezone_t sp, int a, int b);
static int tzload(timezone_t sp, const char * name,
int doextend);
@ -258,7 +259,7 @@ extern long timezone __RENAME(__timezone13);
#endif /* defined USG_COMPAT */
#ifdef ALTZONE
time_t altzone = 0;
long altzone = 0;
#endif /* defined ALTZONE */
static int_fast32_t
@ -273,15 +274,15 @@ detzcode(const char *const codep)
return result;
}
static time_t
static int_fast64_t
detzcode64(const char *const codep)
{
time_t result;
int_fast64_t result;
int i;
result = (time_t)((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;
}
@ -440,6 +441,7 @@ tzload(timezone_t sp, const char *name, const int doextend)
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);
@ -464,15 +466,36 @@ tzload(timezone_t sp, const char *name, const int doextend)
ttisstdcnt + /* ttisstds */
ttisgmtcnt) /* ttisgmts */
goto oops;
timecnt = 0;
for (i = 0; i < sp->timecnt; ++i) {
sp->ats[i] = (time_t)((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;
}
_DIAGASSERT(__type_fit(time_t, at));
sp->ats[timecnt++] = (time_t)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;
}
for (i = 0; i < sp->typecnt; ++i) {
struct ttinfo * ttisp;
@ -528,44 +551,6 @@ tzload(timezone_t sp, const char *name, const int doextend)
}
}
/*
** 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).
*/
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')
@ -574,9 +559,9 @@ tzload(timezone_t sp, const char *name, const int doextend)
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 &&
@ -892,17 +877,16 @@ getrule(const char *strp, 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, const struct rule *const rulep,
const int_fast32_t offset)
static int_fast32_t
transtime(const int year, const struct rule *const rulep,
const int_fast32_t offset)
{
int leapyear;
time_t value;
int_fast32_t value;
int i;
int d, m1, yy0, yy1, yy2, dow;
@ -918,7 +902,7 @@ transtime(const time_t janfirst, const int year, const struct rule *const rulep,
** add SECSPERDAY times the day number-1 to the time of
** January 1, midnight, to get the day.
*/
value = (time_t)(janfirst + (rulep->r_day - 1) * SECSPERDAY);
value = (rulep->r_day - 1) * SECSPERDAY;
if (leapyear && rulep->r_day >= 60)
value += SECSPERDAY;
break;
@ -929,16 +913,13 @@ transtime(const time_t janfirst, const int year, const struct rule *const rulep,
** Just add SECSPERDAY times the day number to the time of
** January 1, midnight, to get the day.
*/
value = (time_t)(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 += (time_t)(mon_lengths[leapyear][i] * SECSPERDAY);
/*
** Use Zeller's Congruence to get day-of-week of first day of
@ -971,17 +952,19 @@ transtime(const time_t janfirst, const int year, const struct rule *const rulep,
/*
** "d" is the day-of-month (zero-origin) of the day we want.
*/
value += (time_t)(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.
*/
return (time_t)(value + rulep->r_time + offset);
return value + rulep->r_time + offset;
}
/*
@ -998,8 +981,6 @@ tzparse(timezone_t sp, const char *name, const int lastditch)
size_t dstlen;
int_fast32_t stdoffset;
int_fast32_t dstoffset;
time_t * atp;
unsigned char * typep;
char * cp;
int load_result;
@ -1058,9 +1039,8 @@ tzparse(timezone_t sp, const char *name, const int lastditch)
struct rule end;
int year;
int yearlim;
int timecnt;
time_t janfirst;
time_t starttime;
time_t endtime;
++name;
if ((name = getrule(name, &start)) == NULL)
@ -1082,47 +1062,47 @@ tzparse(timezone_t sp, const char *name, const int lastditch)
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;
sp->timecnt = 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 += (time_t)yearsecs;
}
_DIAGASSERT(__type_fit(int, atp - sp->ats));
sp->timecnt = (int)(atp - sp->ats);
if (!sp->timecnt)
sp->timecnt = timecnt;
if (!timecnt)
sp->typecnt = 1; /* Perpetual DST. */
} else {
int_fast32_t theirstdoffset;
@ -1639,7 +1619,8 @@ timesub(const timezone_t sp, const time_t *const timep,
if (! ((! TYPE_SIGNED(time_t) || INT_MIN <= tdelta)
&& tdelta <= INT_MAX))
return NULL;
idelta = tdelta;
_DIAGASSERT(__type_fit(int, tdelta));
idelta = (int)tdelta;
if (idelta == 0)
idelta = (tdays < 0) ? -1 : 1;
newy = y;
@ -1798,6 +1779,22 @@ increment_overflow32(int_fast32_t *const lp, int const m)
return FALSE;
}
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)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: private.h,v 1.31 2013/12/13 10:37:24 christos Exp $ */
/* $NetBSD: private.h,v 1.32 2013/12/26 18:34:28 christos Exp $ */
#ifndef PRIVATE_H
#define PRIVATE_H
@ -46,6 +46,10 @@
#define HAVE_INCOMPATIBLE_CTIME_R 0
#endif /* !defined INCOMPATIBLE_CTIME_R */
#ifndef HAVE_LINK
#define HAVE_LINK 1
#endif /* !defined HAVE_LINK */
#ifndef HAVE_SETTIMEOFDAY
#define HAVE_SETTIMEOFDAY 3
#endif /* !defined HAVE_SETTIMEOFDAY */

View File

@ -1,4 +1,4 @@
/* $NetBSD: strftime.c,v 1.29 2013/09/20 19:06:54 christos Exp $ */
/* $NetBSD: strftime.c,v 1.30 2013/12/26 18:34:28 christos Exp $ */
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
@ -6,13 +6,14 @@
static char elsieid[] = "@(#)strftime.c 7.64";
static char elsieid[] = "@(#)strftime.c 8.3";
#else
__RCSID("$NetBSD: strftime.c,v 1.29 2013/09/20 19:06:54 christos Exp $");
__RCSID("$NetBSD: strftime.c,v 1.30 2013/12/26 18:34:28 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <stddef.h>
#include <assert.h>
#include <locale.h>
#include "setlocale_local.h"
@ -495,7 +496,7 @@ label:
continue;
case 'z':
{
int diff;
long diff;
char const * sign;
if (t->tm_isdst < 0)
@ -573,7 +574,8 @@ label:
diff /= SECSPERMIN;
diff = (diff / MINSPERHOUR) * 100 +
(diff % MINSPERHOUR);
pt = _conv(diff, "%04d", pt, ptlim);
_DIAGASSERT(__type_fit(int, diff));
pt = _conv((int)diff, "%04d", pt, ptlim);
}
continue;
#if 0

View File

@ -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"
@ -18,7 +18,7 @@
</head>
<body>
<h1>Sources for Time Zone and Daylight Saving Time Data</h1>
<h2>The <code>tz</code> database</h2>
<h2>The <code><abbr title="time zone">tz</abbr></code> database</h2>
<p>
The <a href="http://en.wikipedia.org/wiki/Public_domain">public-domain</a>
time zone database contains code and data
@ -31,7 +31,8 @@ href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time"><abbr
title="Coordinated Universal Time">UTC</abbr></a> offsets, and
<a href="http://en.wikipedia.org/wiki/Daylight_saving">daylight-saving</a>
rules.
This database (often called <code>zoneinfo</code> or <code>tz</code>)
This database (often called <code>zoneinfo</code> or
<code><abbr>tz</abbr></code>)
is used by several implementations,
including
<a href="http://www.gnu.org/software/libc/">the
@ -40,23 +41,28 @@ C Library</a> (used in
<a href="http://www.linux.org/"><abbr>GNU</abbr>/Linux</a>),
<a href="http://www.android.com/">Android</a>,
<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS">Firefox
OS</a>,
<a href="http://www.freebsd.org/">FreeBSD</a>,
<a href="http://netbsd.org/">NetBSD</a>,
<a href="http://openbsd.org/">OpenBSD</a>,
<abbr title="Operating System">OS</abbr></a>,
<a href="http://www.freebsd.org/">Free<abbr
title="Berkeley Software Distribution">BSD</abbr></a>,
<a href="http://netbsd.org/">Net<abbr>BSD</abbr></a>,
<a href="http://openbsd.org/">Open<abbr>BSD</abbr></a>,
<a href="http://cygwin.com/">Cygwin</a>,
<a href="http://www.delorie.com/djgpp/"><abbr
title="DJ's GNU Programming Platform">DJGPP</abbr></a>,
<a href="http://en.wikipedia.org/wiki/WebOS">webOS</a>,
<a href="http://ibm.com/aix">AIX</a>,
<a href="http://en.wikipedia.org/wiki/WebOS"><abbr
title="Web Operating System">webOS</abbr></a>,
<a href="http://ibm.com/aix"><abbr
title="Advanced Interactive eXecutive">AIX</abbr></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://h71000.www7.hp.com/">OpenVMS</a>,
<a href="http://www.apple.com/ios/"><abbr
title="iPhone OS">iOS</abbr></a>,
<a href="http://windows.microsoft.com/">Microsoft Windows</a>,
<a href="http://h71000.www7.hp.com/">Open<abbr
title="Virtual Memory System">VMS</abbr></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/"><abbr title="Operating System Ten">OS
X</abbr></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.
@ -75,10 +81,11 @@ and switched back in 2006.
To use the database on an extended <a
href="http://en.wikipedia.org/wiki/POSIX"><abbr
title="Portable Operating System Interface">POSIX</abbr></a>
implementation set the <code>TZ</code> environment variable to
the location's full name, e.g., <code>TZ="America/New_York"</code>.</p>
implementation set the <code><abbr>TZ</abbr></code>
environment variable to the location's full name,
e.g., <code><abbr>TZ</abbr>="America/New_York"</code>.</p>
<p>
In the <code>tz</code> database's
In the <code><abbr>tz</abbr></code> database's
<a href="ftp://ftp.iana.org/tz/releases/"><abbr
title="File Transfer Protocol">FTP</abbr> releases</a>
the code is in the file <code>tzcode<var>C</var>.tar.gz</code>,
@ -99,8 +106,10 @@ see the downloaded
<code>README</code> file for what to do next.</p>
<pre style="margin-left: 2em"><code>mkdir tz
cd tz
<a href="http://www.gnu.org/software/wget/">wget</a> --retr-symlinks 'ftp://ftp.iana.org/tz/tz*-latest.tar.gz'
<a href="http://www.gnu.org/software/gzip/">gzip</a> -dc tzcode-latest.tar.gz | <a href="http://www.gnu.org/software/tar/">tar</a> -xf -
<a href="http://www.gnu.org/software/wget/">wget</a> --retr-symlinks
'ftp://ftp.iana.org/tz/tz*-latest.tar.gz'
<a href="http://www.gnu.org/software/gzip/">gzip</a> -dc tzcode-latest.tar.gz |
<a href="http://www.gnu.org/software/tar/">tar</a> -xf -
gzip -dc tzdata-latest.tar.gz | tar -xf -
</code></pre>
<p>
@ -114,9 +123,9 @@ in <a href="http://git-scm.com/">Git</a> form
from <a href="https://github.com/">GitHub</a>; be careful, as this
repository is less well tested and probably contains more errors.
<p>
The code lets you compile the <code>tz</code> source files into
The code lets you compile the <code><abbr>tz</abbr></code> source files into
machine-readable binary files, one for each location. It also lets
you read a <code>tz</code> binary file and interpret time stamps for that
you read a <code><abbr>tz</abbr></code> binary file and interpret time stamps for that
location.</p>
<p>
The data are by no means authoritative. If you find errors, please
@ -135,30 +144,33 @@ For Comments">RFC</abbr> 6557).</p>
The Web has several other sources for time zone and daylight saving time data.
Here are some links that may be of interest.
</p>
<h2>Commentary on the <code>tz</code> database</h2>
<h2>Commentary on the <code><abbr>tz</abbr></code> database</h2>
<ul>
<li>The article
<a href="http://en.wikipedia.org/wiki/Tz_database">tz database</a> is
an encyclopedic summary.</li>
<li><a href="http://www.cstdbill.com/tzdb/tz-how-to.html">How to Read the
tz Database Source Files</a> explains the tz database format.</li>
<li><a href="http://blog.jonudell.net/2009/10/23/a-literary-appreciation-of-the-olsonzoneinfotz-database/">A
<li><a
href="http://blog.jonudell.net/2009/10/23/a-literary-appreciation-of-the-olsonzoneinfotz-database/">A
literary appreciation of the Olson/Zoneinfo/tz database</a> comments on the
database's style.</li>
</ul>
<h2>Web sites using recent versions of the <code>tz</code> database</h2>
<h2>Web sites using recent versions of the <code><abbr>tz</abbr></code> database</h2>
<p>
These are listed roughly in ascending order of complexity and fanciness.
</p>
<ul>
<li><a href="http://twiki.org/cgi-bin/xtra/tzdatepick.html">Date and Time Gateway</a>
lets you see the <code>TZ</code> values directly.</li>
<li><a
href="http://twiki.org/cgi-bin/xtra/tzdatepick.html">Date and Time Gateway</a>
lets you see the <code><abbr>TZ</abbr></code> values directly.</li>
<li><a
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>
<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 &ndash;
Time Zones</a> lets you sort zone names and convert times.</li>
@ -168,7 +180,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>
@ -186,16 +198,16 @@ data; see its VTIMEZONE calendar component.
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
recommendations for the use of VTIMEZONE and <code><abbr>tz</abbr></code>.</li>
<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
registration process that would establish unique names for each
version of each <code>tz</code> zone, along with a polygonal
version of each <code><abbr>tz</abbr></code> zone, along with a polygonal
representation of the geographical area corresponding to the
zone.</li>
<li>The <a
@ -205,100 +217,113 @@ href="http://www.w3.org/RDF/"><abbr
title="Resource Description Framework">RDF</abbr></a>-based calendar
and group scheduling systems, and has a <a
href="http://www.w3.org/2002/12/cal/#tzd">workspace on time zone
data</a> converted from <code>tz</code>. An earlier <a
data</a> converted from <code><abbr>tz</abbr></code>. An earlier <a
href="http://www.w3.org/2000/01/foo">schema</a> was sketched out.</li>
</ul>
<h2>Other <code>tz</code> compilers</h2>
<h2>Other <code><abbr>tz</abbr></code> compilers</h2>
<ul>
<li><a href="http://sourceforge.net/projects/vzic/">Vzic iCalendar
Timezone Converter</a> describes a <a
href="http://en.wikipedia.org/wiki/C_%28programming_language%29">C</a>
program that compiles
<code>tz</code> source into iCalendar-compatible VTIMEZONE files.
<code><abbr>tz</abbr></code> source into iCalendar-compatible VTIMEZONE files.
Vzic is freely
available under the <a
href="http://www.gnu.org/copyleft/gpl.html"><abbr>GNU</abbr>
General Public License (<abbr
title="General Public License">GPL</abbr>)</a>.</li>
<li><a href="http://sourceforge.net/projects/tzical">tziCal - tz
<li><a href="http://sourceforge.net/projects/tzical">tziCal &ndash; tz
database conversion utility</a> is like Vzic, except for the <a
href="http://msdn.microsoft.com/netframework">.NET framework</a>.</li>
<li><a
href="http://search.cpan.org/dist/DateTime-TimeZone/">DateTime::TimeZone</a>
contains a script <code>parse_olson</code> that compiles
<code>tz</code> source into <a href="http://www.perl.org/">Perl</a>
<code><abbr>tz</abbr></code> source into <a href="http://www.perl.org/">Perl</a>
modules. It is part of the Perl <a
href="http://datetime.perl.org/">DateTime Project</a>, which is freely
available under both the <abbr>GPL</abbr> and the Perl Artistic
License. DateTime::TimeZone also contains a script
<code>tests_from_zdump</code> that generates test cases for each clock
transition in the <code>tz</code> database.</li>
transition in the <code><abbr>tz</abbr></code> database.</li>
<li><a href="http://icu-project.org/">International Components for
Unicode (<abbr>ICU</abbr>)</a> contains C/C++ and <a
href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a>
libraries for internationalization that
has a compiler from <code>tz</code> source
has a compiler from <code><abbr>tz</abbr></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
<abbr>BSD</abbr>-style license.</li>
<li><a href="http://www.joda.org/joda-time/">Joda Time &ndash; 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
<code><abbr>tz</abbr></code> source into a Joda-specific binary format. Joda Time
is freely available under a <abbr>BSD</abbr>-style license.</li>
<li><a href="http://pytz.sourceforge.net">pytz - World Timezone
Definitions for Python</a> compiles <code>tz</code> source into
<li><a href="http://nodatime.org/">Noda Time &ndash; Date and time API
for .NET</a> is similar to Joda Time, but for the .NET framework
instead of Java. It is freely available under the
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License</a>.</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><abbr>tz</abbr></code> source files and interprets time
stamps using an API that is upward compatible with standard JavaScript
Dates. It is freely available under the Apache License.</li>
<li><a href="http://pytz.sourceforge.net">pytz &ndash; World Timezone
Definitions for Python</a> compiles <code><abbr>tz</abbr></code> source into
<a href="http://python.org/">Python</a>.
It is freely available under a <abbr>BSD</abbr>-style license.</li>
<li><a href="http://tzinfo.rubyforge.org/">TZInfo - Ruby Timezone Library</a>
compiles <code>tz</code> source into
<li><a href="http://tzinfo.rubyforge.org/">TZInfo &ndash;
Ruby Timezone Library</a>
compiles <code><abbr>tz</abbr></code> source into
<a href="http://www.ruby-lang.org/en/">Ruby</a>.
It is freely available under the <abbr
title="Massachusetts Institute of Technology">MIT</abbr> license.</li>
<li>The <a href="http://www.squeaksource.com/Chronos/">Chronos Date/Time
Library</a> is
a <a href="http://en.wikipedia.org/wiki/Smalltalk">Smalltalk</a> class
library that compiles <code>tz</code> source into a time zone repository whose format
library that compiles <code><abbr>tz</abbr></code> source into a time
zone repository whose format
is either proprietary or an <a href="http://www.w3.org/XML/"><abbr
title="Extensible Markup Language">XML</abbr></a>-encoded
representation.</li>
<li>Starting with version 8.5, <a href="http://tcl.tk/">Tcl</a>
contains a developer-oriented parser that compiles <samp>tz</samp>
contains a developer-oriented parser that compiles <code><abbr>tz</abbr></code>
source into text files, along with a runtime that can read those
files. Tcl is freely available under a <abbr>BSD</abbr>-style
license.</li>
</ul>
<h2>Other <code>tz</code> binary file readers</h2>
<h2>Other <code><abbr>tz</abbr></code> binary file readers</h2>
<ul>
<li>The <a
href="http://www.gnu.org/software/libc/"><abbr>GNU</abbr> C
Library</a>
has an independent, thread-safe implementation of
a <code>tz</code> binary file reader.
a <code><abbr>tz</abbr></code> binary file reader.
This library is freely available under the
<a href="http://www.gnu.org/copyleft/lesser.html">
<abbr>GNU</abbr> Lesser General Public License
(<abbr title="Lesser General Public License">LGPL</abbr>)</a>,
and is widely used in <abbr>GNU</abbr>/Linux systems.</li>
<li><a href="http://bmsi.com/java/#TZ">ZoneInfo.java</a>
is a <code>tz</code> binary file reader written in Java.
is a <code><abbr>tz</abbr></code> binary file reader written in Java.
It is freely available under the <abbr>LGPL</abbr>.</li>
<li>Tcl, mentioned above, also contains a
<code>tz</code> binary file reader.</li>
<code><abbr>tz</abbr></code> binary file reader.</li>
<li><a href="http://search.cpan.org/perldoc?DateTime::TimeZone::Tzfile">
DateTime::TimeZone::Tzfile</a>
is a <code>tz</code> binary file reader written in Perl.
is a <code><abbr>tz</abbr></code> binary file reader written in Perl.
It is freely available under the same terms as Perl
(dual <abbr>GPL</abbr> and Artistic license).</li>
<li>The
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
library contains a Python tool that
converts <code><abbr>tz</abbr></code> binary data into
<a href="http://www.json.org/"><abbr title="JavaScript Object
Notation">JSON</abbr></a>-format data suitable for use
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>
<h2>Other <code><abbr>tz</abbr></code>-based time zone software</h2>
<ul>
<li><a href="http://foxclocks.org/">FoxClocks</a>
is an extension for <a href="http://google.com/chrome">Google
@ -315,9 +340,10 @@ href="http://users.skynet.be/Peter.Verthez/projects/intclock/">International
clock (intclock)</a> is a multi-timezone clock for
<abbr>GNU</abbr>/Linux and similar systems. It is freely available
under the <abbr>GPL</abbr>.</li>
<li><a href="http://www.oracle.com/us/technologies/java/overview/index.html">Oracle
<li><a
href="http://www.oracle.com/us/technologies/java/overview/index.html">Oracle
Java</a> releases since 1.4
contain a copy of a subset of a recent <code>tz</code> database in a
contain a copy of a subset of a recent <code><abbr>tz</abbr></code> database in a
Java-specific format.</li>
<li><a href="http://kimmo.suominen.com/sw/timezone/">Time Zone</a> is
a <a href="http://wordpress.org/">WordPress</a> plugin. It is freely
@ -328,9 +354,9 @@ download, compile and use the <code>tzdata<var>D</var>.tar.gz</code>
files as they are released. The Basic version is free.</li>
<li><a
href="http://veladg.com/velaterra.html">VelaTerra</a> is
a Mac OS X program. Its developers
a Mac <abbr>OS X</abbr> program. Its developers
<a href="http://veladg.com/tzoffer.html">offer free
licenses</a> to <code>tz</code> contributors.</li>
licenses</a> to <code><abbr>tz</abbr></code> contributors.</li>
<li><a
href="http://worldtimeexplorer.com/">World Time Explorer</a> is a
Microsoft Windows program.</li>
@ -356,15 +382,16 @@ is another time zone database.</li>
<li><a href="http://tycho.usno.navy.mil/tzones.html">World Time Zones</a>
contains data from the Time Service Department of the
<abbr>US</abbr> Naval Observatory, used as the source
for the <code>usno*</code> files in the <code>tz</code> distribution.</li>
for the <code><abbr>usno</abbr>*</code> files in
the <code><abbr>tz</abbr></code> distribution.</li>
<li>The <a href="http://www.iata.org/publications/Pages/ssim.aspx">Standard
Schedules Information Manual</a> of the
<a href="http://iata.org/index.htm">International Air Transport
Association</a>
gives current time zone rules for airports served by commercial aviation.</li>
<li>Some Microsoft Windows versions contain time zone information in
an undocumented format, with IDs that can be mapped to <code>TZ</code>
values using the <a
an undocumented format, with <abbr>ID</abbr>s that can be mapped to
<code><abbr>TZ</abbr></code> values using the <a
href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">Zone
&rarr; Tzid table</a> maintained by the <abbr
title="Common Locale Data Repository">CLDR</abbr> data mentioned
@ -394,16 +421,17 @@ but the maps are more up to date.</li>
</ul>
<h2>Time zone boundaries</h2>
<ul>
<li><a href="http://efele.net/maps/tz/">TZ timezones maps</a> contains <a
<li><a href="http://efele.net/maps/tz/"><abbr>TZ</abbr> timezones
maps</a> contains <a
href="http://en.wikipedia.org/wiki/Shapefile">shapefiles</a> of
sets of <code>tz</code> regions.</li>
sets of <code><abbr>tz</abbr></code> regions.</li>
<li><a href="http://derickrethans.nl/what-time-is-it.html">What Time
is It Here?</a> applies <a href="http://www.mongodb.org/">MongoDB</a>
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
@ -422,7 +450,8 @@ Time Zones and Time Zone Data</a>.</li>
href="http://en.wikipedia.org/wiki/Territorial_waters">territorial
waters</a> of any nation uses that nation's time. In international
waters, time zone boundaries are meridians 15&deg; apart, except that
UTC&minus;12 and UTC+12 are each 7.5&deg; wide and are separated by
<abbr>UTC</abbr>&minus;12 and <abbr>UTC</abbr>+12 are each 7.5&deg;
wide and are separated by
the 180&deg; meridian (not by the International Date Line, which is
for land and territorial waters only). A captain can change ship's
clocks any time after entering a new time zone; midnight changes are
@ -434,7 +463,7 @@ common.</li>
Walk through Time</a>
surveys the evolution of timekeeping.</li>
<li><a href="http://webexhibits.org/daylightsaving/">About Daylight
Saving Time - History, rationale, laws &amp; dates</a>
Saving Time &ndash; History, rationale, laws &amp; dates</a>
is an overall history of <abbr>DST</abbr>.</li>
<li><a href="http://www.w3.org/TR/timezone/">Working with Time Zones</a>
contains guidelines and best practices for software applications that
@ -461,8 +490,9 @@ Zone Concepts</a> discusses terminological issues behind time zones.</li>
<dd>The Parliamentary Library has commissioned <a
href="http://www.aph.gov.au/binaries/library/pubs/rn/2006-07/07rn13.pdf">research
note on daylight saving time in Australia</a>.
The Bureau of Meteorology publishes a list of
<a href="http://www.bom.gov.au/climate/averages/tables/dst_times.shtml">Implementation Dates of Daylight Savings Time within Australia</a>.</dd>
The Bureau of Meteorology publishes a list of <a
href="http://www.bom.gov.au/climate/averages/tables/dst_times.shtml">Implementation
Dates of Daylight Savings Time within Australia</a>.</dd>
<dt>Belgium</dt>
<dd>The Royal Observatory of Belgium maintains a table of <a
href="http://www.astro.oma.be/GENERAL/INFO/nli001a.html"
@ -479,12 +509,12 @@ href="http://www.nrc-cnrc.gc.ca/eng/services/time/time_zones.html">time
zones &amp; 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
Legal Time in Germany</a>.</dd>
href="http://www.ptb.de/cms/en/fachabteilungen/abt4/fb-44/ag-441/realisation-of-legal-time-in-germany.html">Realisation
of Legal Time in Germany</a>.</dd>
<dt>Israel</dt>
<dd>The Interior Ministry periodically issues <a
href="ftp://ftp.cs.huji.ac.il/pub/tz/announcements"
@ -536,7 +566,7 @@ href="http://tools.ietf.org/html/rfc4833">Timezone
Options for <abbr title="Dynamic Host Configuration Protocol">DHCP</abbr></a>
(Internet <abbr>RFC</abbr> 4833)
specifies a <a
href="http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP</a>
href="http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol"><abbr>DHCP</abbr></a>
option for a server to configure
a client's time zone and daylight saving settings automatically.</li>
<li><a href="http://gauss.gge.unb.ca/GMT.UT.and.the.RGO.html">A Few
@ -557,13 +587,13 @@ 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
<abbr>UTC</abbr>.</li>
<li><a href="http://www2.jpl.nasa.gov/basics/bsf2-3.php">Basics of
Space Flight - Reference Systems - Time Conventions</a>
Space Flight &ndash; Reference Systems &ndash; Time Conventions</a>
briefly explains interplanetary space flight timekeeping.</li>
<li><a
href="http://www.giss.nasa.gov/tools/mars24/help/notes.html">Technical
@ -577,7 +607,8 @@ dedicated not only to leap seconds but to precise time and frequency
in general. It covers the state of the art in amateur timekeeping, and
how the art has progressed over the past few decades.</li>
<li><a
href="http://www.iers.org/IERS/EN/Publications/Bulletins/bulletins.html">IERS
href="http://www.iers.org/IERS/EN/Publications/Bulletins/bulletins.html"><abbr
title="International Earth Rotation and Reference Systems Service">IERS</abbr>
Bulletins</a> contains official publications of the International
Earth Rotation and Reference Systems Service, which decides
when leap seconds occur.</li>
@ -589,7 +620,8 @@ and Klepczynski's proposal to discontinue leap seconds</a>,
discussed further in
<a href="http://www.cl.cam.ac.uk/~mgk25/time/metrologia-leapsecond.pdf">The
leap second: its history and possible future</a>.
<a href="http://www.ucolick.org/~sla/leapsecs/">UTC might be redefined
<a href="http://www.ucolick.org/~sla/leapsecs/"><abbr>UTC</abbr>
might be redefined
without Leap Seconds</a> gives pointers on this
contentious issue.</li>
</ul>
@ -602,12 +634,12 @@ summary of
<a
href="http://www.iso.org/iso/catalogue_detail?csnumber=40874"><abbr
title="International Organization for Standardization">ISO</abbr>
8601:2004 -- Data elements and interchange formats -- Information
interchange -- Representation of dates and times</a>.</li>
8601:2004 &ndash; Data elements and interchange formats &ndash; Information
interchange &ndash; Representation of dates and times</a>.</li>
<li>
<a href="http://www.w3.org/TR/xmlschema-2/#dateTime"><abbr>XML</abbr>
Schema: Datatypes - dateTime</a> specifies a format inspired by
<abbr>ISO</abbr> 8601 that is in common use in XML data.</li>
Schema: Datatypes &ndash; dateTime</a> specifies a format inspired by
<abbr>ISO</abbr> 8601 that is in common use in <abbr>XML</abbr> data.</li>
<li>
<a href="http://tools.ietf.org/html/rfc5322">Internet
Message Format</a> (Internet <abbr>RFC</abbr> 5322) &sect;3.3
@ -645,22 +677,24 @@ practice. For example, "<abbr>EST</abbr>" denotes 5 hours behind
or 11 hours ahead of <abbr>UTC</abbr> in Australia; and
French-speaking North Americans prefer
"<abbr title="Heure Normale de l'Est">HNE</abbr>" to
"<abbr>EST</abbr>". For <abbr>POSIX</abbr> the <code>tz</code>
"<abbr>EST</abbr>". For <abbr>POSIX</abbr> the <code><abbr>tz</abbr></code>
database contains English abbreviations for all time stamps but in
many cases these are merely inventions of the database
maintainers.</li>
<li>Numeric time zone abbreviations typically count hours east of
<abbr>UTC</abbr>, e.g., <code>+09</code> for Japan and
<code>-10</code> for Hawaii. However, the <abbr>POSIX</abbr>
<code>TZ</code> environment variable uses the opposite convention. For
example, one might use <code>TZ="JST-9"</code> and
<code>TZ="HST10"</code> for Japan and Hawaii, respectively. If the
<code>tz</code> database is available, it is usually better to use
settings like <code>TZ="Asia/Tokyo"</code> and
<code>TZ="Pacific/Honolulu"</code> instead, as this should avoid
<code><abbr>TZ</abbr></code> environment variable uses the opposite convention.
For example, one might use <code><abbr>TZ</abbr>="<abbr
title="Japan Standard Time">JST</abbr>-9"</code> and
<code><abbr>TZ</abbr>="<abbr title="Hawaii Standard
Time">HST</abbr>10"</code> for Japan and Hawaii, respectively. If the
<code><abbr>tz</abbr></code> database is available, it is usually better to use
settings like <code><abbr>TZ</abbr>="Asia/Tokyo"</code> and
<code><abbr>TZ</abbr>="Pacific/Honolulu"</code> instead, as this should avoid
confusion, handle old time stamps better, and insulate you better from
any future changes to the rules. One should never set
<abbr>POSIX</abbr> <code>TZ</code> to a value like
<abbr>POSIX</abbr> <code><abbr>TZ</abbr></code> to a value like
<code>"GMT-9"</code>, though, since this would falsely claim that
local time is nine hours ahead of <abbr>UTC</abbr> and the time zone
is called "<abbr>GMT</abbr>".</li>
@ -668,14 +702,14 @@ is called "<abbr>GMT</abbr>".</li>
<h2>Related indexes</h2>
<ul>
<li><a href="tz-art.htm">Time and the Arts</a></li>
<li><a href="http://www.dmoz.org/Reference/Time/">Open Directory -
<li><a href="http://www.dmoz.org/Reference/Time/">Open Directory &ndash;
Reference: Time</a></li>
<li><a href="http://dir.yahoo.com/Science/Measurements_and_Units/Time">Yahoo!
Directory &gt; Science &gt; Measurements and Units &gt; Time</a></li>
</ul>
<hr>
<address>
This file is in the public domain, so clarified as of
This web page is in the public domain, so clarified as of
2009-05-17 by Arthur David Olson.
<br>
Please send corrections to this web page to the

View File

@ -1,4 +1,4 @@
/* $NetBSD: tzfile.h,v 1.12 2013/09/20 19:06:54 christos Exp $ */
/* $NetBSD: tzfile.h,v 1.13 2013/12/26 18:34:28 christos Exp $ */
#ifndef TZFILE_H
#define TZFILE_H
@ -102,16 +102,8 @@ struct tzhead {
#endif /* !defined TZ_MAX_TIMES */
#ifndef TZ_MAX_TYPES
#ifndef NOSOLAR
/* This must be at least 17 for Europe/Samara and Europe/Vilnius. */
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
#endif /* !defined NOSOLAR */
#ifdef NOSOLAR
/*
** Must be at least 14 for Europe/Riga as of Jan 12 1995,
** as noted by Earl Chew.
*/
#define TZ_MAX_TYPES 20 /* Maximum number of local time types */
#endif /* !defined NOSOLAR */
#endif /* !defined TZ_MAX_TYPES */
#ifndef TZ_MAX_CHARS

View File

@ -1,6 +1,6 @@
#! /bin/bash
#
# $NetBSD: tzselect.ksh,v 1.9 2013/09/20 19:06:54 christos Exp $
# $NetBSD: tzselect.ksh,v 1.10 2013/12/26 18:34:28 christos Exp $
#
PKGVERSION='(tzcode) '
TZVERSION=see_Makefile
@ -13,7 +13,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
@ -23,6 +23,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:
@ -33,7 +37,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
@ -69,6 +73,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
@ -87,7 +159,7 @@ do
esac
done
shift $((OPTIND-1))
shift `expr $OPTIND - 1`
case $# in
0) ;;
*) echo >&2 "$0: $1: unknown argument"; exit 1 ;;
@ -109,11 +181,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='
@ -193,8 +260,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")
@ -207,30 +275,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
@ -267,39 +326,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
@ -316,7 +371,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.
@ -324,28 +379,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) {
@ -355,7 +402,7 @@ while
}
}
$1 == cc { print $4 }
' <$TZ_ZONE_TABLE)
' <$TZ_ZONE_TABLE`
# If there's more than one region, ask the user which one.
@ -363,27 +410,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) {
@ -393,7 +433,7 @@ while
}
}
$1 == cc && $4 == region { print $3 }
' <$TZ_ZONE_TABLE)
' <$TZ_ZONE_TABLE`
esac
# Make sure the corresponding zoneinfo file exists.
@ -412,10 +452,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="
@ -442,16 +482,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=

View File

@ -1,5 +1,5 @@
.\" $NetBSD: tzset.3,v 1.26 2013/09/20 19:06:54 christos Exp $
.Dd September 20, 2013
.\" $NetBSD: tzset.3,v 1.27 2013/12/26 18:34:28 christos Exp $
.Dd December 26, 2013
.Dt TZSET 3
.Os
.Sh NAME
@ -226,8 +226,8 @@ values that directly specify the time zone rules; they use some of the
extensions to POSIX.
.Bl -tag
.It EST5
stands for US eastern
time (EST), 5 hours behind UTC, without daylight saving.
stands for US Eastern Standard
Time (EST), 5 hours behind UTC, without daylight saving.
.It FJT\(mi12FJST,M10.3.1/146,M1.3.4/75
stands for Fiji Time (FJT) and Fiji Summer Time (FJST), 12 hours ahead
of UTC, springing forward on October's third Monday at
@ -249,7 +249,7 @@ all year and the initial
.Em WART
is a placeholder.
.It WGT3WGST,M3.5.0/\(mi2,M10.5.0/\(mi1
stands for Western Greenland time (WGT) and Western Greenland Summer
stands for Western Greenland Time (WGT) and Western Greenland Summer
Time (WGST), 3 hours behind UTC, where clocks follow the EU rules of
springing forward on March's last Sunday at 01:00 UTC (\(mi02:00 local
time) and falling back on October's last Sunday at 01:00 UTC

View File

@ -1,4 +1,4 @@
/* $NetBSD: zdump.c,v 1.31 2013/09/20 19:06:54 christos Exp $ */
/* $NetBSD: zdump.c,v 1.32 2013/12/26 18:34:28 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2009-05-17 by Arthur David Olson.
@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: zdump.c,v 1.31 2013/09/20 19:06:54 christos Exp $");
__RCSID("$NetBSD: zdump.c,v 1.32 2013/12/26 18:34:28 christos Exp $");
#endif /* !defined lint */
#include "version.h"
@ -62,6 +62,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
@ -70,13 +71,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
@ -380,16 +379,19 @@ main(int argc, char *argv[])
if (vflag | Vflag) {
intmax_t lo;
intmax_t hi;
char dummy;
char *loend, *hiend;
intmax_t cutloyear = ZDUMP_LO_YEAR;
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);
@ -401,14 +403,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;

View File

@ -1,4 +1,4 @@
/* $NetBSD: zic.c,v 1.43 2013/09/20 19:06:54 christos Exp $ */
/* $NetBSD: zic.c,v 1.44 2013/12/26 18:34:28 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2006-07-17 by Arthur David Olson.
@ -10,7 +10,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: zic.c,v 1.43 2013/09/20 19:06:54 christos Exp $");
__RCSID("$NetBSD: zic.c,v 1.44 2013/12/26 18:34:28 christos Exp $");
#endif /* !defined lint */
#include "version.h"
@ -118,6 +118,13 @@ extern int link(const char * fromname, const char * toname);
extern char * optarg;
extern int optind;
#if ! HAVE_LINK
# define link(from, to) (-1)
#endif
#if ! HAVE_SYMLINK
# define symlink(from, to) (-1)
#endif
static void addtt(zic_t starttime, int type);
static int addtype(zic_t gmtoff, const char * abbr, int isdst,
int ttisstd, int ttisgmt);
@ -626,41 +633,71 @@ dolink(const char *const fromfield, const char *const tofield)
*/
if (!itsdir(toname))
(void) remove(toname);
if (link(fromname, toname) != 0) {
if (link(fromname, toname) != 0
&& access(fromname, F_OK) == 0 && !itsdir(fromname)) {
int result;
if (mkdirs(toname) != 0)
exit(EXIT_FAILURE);
result = link(fromname, toname);
#if HAVE_SYMLINK
if (result != 0 &&
access(fromname, F_OK) == 0 &&
!itsdir(fromname)) {
const char *s = tofield;
if (result != 0) {
const char *s = fromfield;
const char *t;
char * symlinkcontents = NULL;
while ((s = strchr(s+1, '/')) != NULL)
do
t = s;
while ((s = strchr(s, '/'))
&& ! strncmp (fromfield, tofield,
++s - fromfield));
for (s = tofield + (t - fromfield);
(s = strchr(s, '/'));
s++)
symlinkcontents =
ecatalloc(symlinkcontents,
"../");
symlinkcontents =
ecatalloc(symlinkcontents,
fromname);
result = symlink(symlinkcontents,
toname);
symlinkcontents = ecatalloc(symlinkcontents, t);
result = symlink(symlinkcontents, toname);
if (result == 0)
warning(_("hard link failed, symbolic link used"));
free(symlinkcontents);
}
#endif /* HAVE_SYMLINK */
if (result != 0) {
const char *e = strerror(errno);
(void) fprintf(stderr,
_("%s: Can't link from %s to %s: %s\n"),
progname, fromname, toname, e);
exit(EXIT_FAILURE);
FILE *fp, *tp;
int c;
fp = fopen(fromname, "rb");
if (!fp) {
const char *e = strerror(errno);
(void) fprintf(stderr,
_("%s: Can't read %s: %s\n"),
progname, fromname, e);
exit(EXIT_FAILURE);
}
tp = fopen(toname, "wb");
if (!tp) {
const char *e = strerror(errno);
(void) fprintf(stderr,
_("%s: Can't create %s: %s\n"),
progname, toname, e);
exit(EXIT_FAILURE);
}
while ((c = getc(fp)) != EOF)
putc(c, tp);
if (ferror(fp) || fclose(fp)) {
(void) fprintf(stderr,
_("%s: Error reading %s\n"),
progname, fromname);
exit(EXIT_FAILURE);
}
if (ferror(tp) || fclose(tp)) {
(void) fprintf(stderr,
_("%s: Error writing %s\n"),
progname, toname);
exit(EXIT_FAILURE);
}
warning(_("link failed, copy used"));
}
}
free(fromname);
@ -2079,12 +2116,12 @@ outzone(const struct zone *const zpfirst, const int zonecount)
compat = stringzone(envvar, max_envvar_len + 1, zpfirst, zonecount);
version = compat < 2013 ? ZIC_VERSION_PRE_2013 : ZIC_VERSION;
do_extend = compat < 0 || compat == YEAR_BY_YEAR_ZONE;
if (noise && compat != 0 && compat != YEAR_BY_YEAR_ZONE) {
if (compat < 0)
if (noise) {
if (!*envvar)
warning("%s %s",
_("no POSIX environment variable for zone"),
zpfirst->z_name);
else {
else if (compat != 0 && compat != YEAR_BY_YEAR_ZONE) {
/* Circa-COMPAT clients, and earlier clients, might
not work for this zone when given dates before
1970 or after 2038. */