Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/time Welcome to tzcode 2013e:



details:   https://anonhg.NetBSD.org/src/rev/612bf9308578
branches:  trunk
changeset: 790132:612bf9308578
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Sep 20 19:06:54 2013 +0000

description:
Welcome to tzcode 2013e:

  Changes affecting API

    The 'zic' command now outputs a dummy transition when far-future
    data can't be summarized using a TZ string, and uses a 402-year
    window rather than a 400-year window.  For the current data, this
    affects only the Asia/Tehran file.  It does not affect any of the
    time stamps that this file represents, so zdump outputs the same
    information as before.  (Thanks to Andrew Main (Zefram).)

    The 'date' command has a new '-r' option, which lets you specify
    the integer time to display, a la FreeBSD.

    The 'tzselect' command has two new options '-c' and '-n', which lets you
    select a zone based on latitude and longitude.

    The 'zic' command's '-v' option now warns about constructs that
    require the new version-3 binary file format.  (Thanks to Arthur
    David Olson for the suggestion.)

    Support for floating-point time_t has been removed.
    It was always dicey, and POSIX no longer requires it.
    (Thanks to Eric Blake for suggesting to the POSIX committee to
    remove it, and thanks to Alan Barrett, Clive D.W. Feather, Andy
    Heninger, Arthur David Olson, and Alois Treindl, for reporting
    bugs and elucidating some of the corners of the old floating-point
    implementation.)

    The signatures of 'offtime', 'timeoff', and 'gtime' have been
    changed back to the old practice of using 'long' to represent UT
    offsets.  This had been inadvertently and mistakenly changed to
    'int_fast32_t'.  (Thanks to Christos Zoulos.)

    The code avoids undefined behavior on integer overflow in some
    more places, including gmtime, localtime, mktime and zdump.

  Changes affecting the zdump utility

    zdump now outputs "UT" when referring to Universal Time, not "UTC".
    "UTC" does not make sense for time stamps that predate the introduction
    of UTC, whereas "UT", a more-generic term, does.  (Thanks to Steve Allen
    for clarifying UT vs UTC.)

  Data changes affecting behavior of tzselect and similar programs

    Country code BQ is now called the more-common name "Caribbean Netherlands"
    rather than the more-official "Bonaire, St Eustatius & Saba".

    Remove from zone.tab the names America/Montreal, America/Shiprock,
    and Antarctica/South_Pole, as they are equivalent to existing
    same-country-code zones for post-1970 time stamps.  The data for
    these names are unchanged, so the names continue to work as before.

  Changes affecting code internals

    zic -c now runs way faster on 64-bit hosts when given large numbers.

    zic now uses vfprintf to avoid allocating and freeing some memory.

    tzselect now computes the list of continents from the data,
    rather than have it hard-coded.

    Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

  Changes affecting the build procedure

    The 'leapseconds' file is now generated automatically from a
    new file 'leap-seconds.list', which is a copy of
    <ftp://time.nist.gov/pub/leap-seconds.list>.
    A new source file 'leapseconds.awk' implements this.
    The goal is simplification of the future maintenance of 'leapseconds'.

    When building the 'posix' or 'right' subdirectories, if the
    subdirectory would be a copy of the default subdirectory, it is
    now made a symbolic link if that is supported.  This saves about
    2 MB of file system space.

    The links America/Shiprock and Antarctica/South_Pole have been
    moved to the 'backward' file.  This affects only nondefault builds
    that omit 'backward'.

  Changes affecting documentation and commentary

    Changes to the 'tzfile' man page

      It now mentions that the binary file format may be extended in
      future versions by appending data.

      It now refers to the 'zdump' and 'zic' man pages.

    Changes to the 'zic' man page

      It lists conditions that elicit a warning with '-v'.

      It says that the behavior is unspecified when duplicate names
      are given, or if the source of one link is the target of another.

      Its examples are updated to match the latest data.

      The definition of white space has been clarified slightly.
      (Thanks to Michael Deckers.)

    Changes to the 'Theory' file

      There is a new section about the accuracy of the tz database,
      describing the many ways that errors can creep in, and
      explaining why so many of the pre-1970 time stamps are wrong or
      misleading (thanks to Steve Allen, Lester Caine, and Garrett
      Wollman for discussions that contributed to this).

      The 'Theory' file describes LMT better (this follows a
      suggestion by Guy Harris).

      It refers to the 2013 edition of POSIX rather than the 2004 edition.

      It's mentioned that excluding 'backward' should not affect the
      other data, and it suggests at least one zone.tab name per
      inhabited country (thanks to Stephen Colebourne).

      Some longstanding restrictions on names are documented, e.g.,
      'America/New_York' precludes 'America/New_York/Bronx'.

      It gives more reasons for the 1970 cutoff.

      It now mentions which time_t variants are supported, such as
      signed integer time_t.  (Thanks to Paul Goyette for reporting
      typos in an experimental version of this change.)

      (Thanks to Philip Newton for correcting typos in these changes.)

    Documentation and commentary is more careful to distinguish UT in
    general from UTC in particular.  (Thanks to Steve Allen.)

    Add a better source for the Zurich 1894 transition.
    (Thanks to Pierre-Yves Berger.)

    Update shapefile citations in tz-link.htm.  (Thanks to Guy Harris.)

diffstat:

 lib/libc/time/Makefile     |  105 ++++++++------
 lib/libc/time/Theory       |  283 +++++++++++++++++++++++++++++++---------
 lib/libc/time/checktab.awk |   31 ++--
 lib/libc/time/ctime.3      |   58 +++++++-
 lib/libc/time/difftime.c   |   15 +-
 lib/libc/time/localtime.c  |  137 +++++++++----------
 lib/libc/time/private.h    |   33 +++-
 lib/libc/time/strftime.3   |   11 +-
 lib/libc/time/strftime.c   |    6 +-
 lib/libc/time/tz-link.htm  |   17 +-
 lib/libc/time/tzfile.5     |   48 ++++--
 lib/libc/time/tzfile.h     |   15 +-
 lib/libc/time/tzselect.8   |   74 ++++++++++-
 lib/libc/time/tzselect.ksh |  237 +++++++++++++++++++++++++++------
 lib/libc/time/tzset.3      |   57 +++++++-
 lib/libc/time/version.h    |    6 +-
 lib/libc/time/zdump.8      |   24 ++-
 lib/libc/time/zdump.c      |  122 ++++++++--------
 lib/libc/time/zic.8        |   87 +++++++----
 lib/libc/time/zic.c        |  315 +++++++++++++++++++++++++++++++--------------
 20 files changed, 1175 insertions(+), 506 deletions(-)

diffs (truncated from 3079 to 300 lines):

diff -r a5fc941e765f -r 612bf9308578 lib/libc/time/Makefile
--- a/lib/libc/time/Makefile    Fri Sep 20 17:51:04 2013 +0000
+++ b/lib/libc/time/Makefile    Fri Sep 20 19:06:54 2013 +0000
@@ -6,7 +6,7 @@
 PACKAGE=       tzcode
 
 # Version numbers of the code and data distributions.
-VERSION=       2013d
+VERSION=       2013e
 
 # Email address for bug reports.
 BUGEMAIL=      tz%iana.org@localhost
@@ -28,7 +28,7 @@
 # time zone files, or adding it to a time zone file).
 # (When a POSIX-style environment variable is handled, the rules in the
 # template file are used to determine "spring forward" and "fall back" days and
-# times; the environment variable itself specifies UTC offsets of standard and
+# times; the environment variable itself specifies UT offsets of standard and
 # summer time.)
 # Alternately, if you discover you've got the wrong time zone, you can just
 #      zic -p rightzone
@@ -51,7 +51,8 @@
 # (and subdirectories).
 # Use an absolute path name for TZDIR unless you're just testing the software.
 
-TZDIR=         $(TOPDIR)/etc/zoneinfo
+TZDIR_BASENAME=        zoneinfo
+TZDIR=         $(TOPDIR)/etc/$(TZDIR_BASENAME)
 
 # Types to try, as an alternative to time_t.  int64_t should be first.
 TIME_T_ALTERNATIVES= int64_t int32_t uint32_t uint64_t
@@ -120,7 +121,6 @@
 #  -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
 #      if you do not want run time warnings about formats that may cause
 #      year 2000 grief
-#  -DTIME_T_FLOATING=1 if your time_t (or time_tz) is floating point
 #  -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t
 #  -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
 #  -TTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
@@ -188,7 +188,7 @@
 # that gives an offset to add to the time_t when converting it.
 # "timelocal" is equivalent to "mktime".
 # "timegm" is like "timelocal" except that it turns a struct tm into
-# a time_t using UTC (rather than local time as "timelocal" does).
+# a time_t using UT (rather than local time as "timelocal" does).
 # "timeoff" is like "timegm" except that it accepts a second (long) argument
 # that gives an offset to use when converting to a time_t.
 # "posix2time" and "time2posix" are described in an included manual page.
@@ -242,6 +242,8 @@
 zic=           ./zic
 ZIC=           $(zic) $(ZFLAGS)
 
+ZFLAGS=
+
 # The name of a Posix-compliant `awk' on your system.
 AWK=           awk
 
@@ -319,10 +321,12 @@
 SDATA=         solar87 solar88 solar89
 TDATA=         $(YDATA) $(NDATA) $(SDATA)
 TABDATA=       iso3166.tab zone.tab
-DATA=          $(YDATA) $(NDATA) $(SDATA) $(TABDATA) leapseconds yearistype.sh
+DATA=          $(YDATA) $(NDATA) $(SDATA) $(TABDATA) \
+                       leap-seconds.list yearistype.sh
 WEB_PAGES=     tz-art.htm tz-link.htm
+AWK_SCRIPTS=   checktab.awk leapseconds.awk
 MISC=          usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \
-                       $(WEB_PAGES) checktab.awk workman.sh \
+                       $(WEB_PAGES) $(AWK_SCRIPTS) workman.sh \
                        zoneinfo2tdf.pl
 ENCHILADA=     $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC)
 
@@ -331,35 +335,38 @@
 
 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) $(DESTDIR)$(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)/.
-               -mkdir $(TOPDIR) $(ETCDIR)
-               cp tzselect zic zdump $(ETCDIR)/.
-               -mkdir $(TOPDIR) $(MANDIR) \
-                       $(MANDIR)/man3 $(MANDIR)/man5 $(MANDIR)/man8
-               -rm -f $(MANDIR)/man3/newctime.3 \
-                       $(MANDIR)/man3/newtzset.3 \
-                       $(MANDIR)/man5/tzfile.5 \
-                       $(MANDIR)/man8/tzselect.8 \
-                       $(MANDIR)/man8/zdump.8 \
-                       $(MANDIR)/man8/zic.8
-               cp newctime.3 newtzset.3 $(MANDIR)/man3/.
-               cp tzfile.5 $(MANDIR)/man5/.
-               cp tzselect.8 zdump.8 zic.8 $(MANDIR)/man8/.
+                       -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) \
+                       $(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/.
 
 INSTALL:       ALL install date.1
-               -mkdir $(TOPDIR) $(BINDIR)
-               cp date $(BINDIR)/.
-               -mkdir $(TOPDIR) $(MANDIR) $(MANDIR)/man1
-               -rm -f $(MANDIR)/man1/date.1
-               cp date.1 $(MANDIR)/man1/.
+               -mkdir $(DESTDIR)$(TOPDIR) $(DESTDIR)$(BINDIR)
+               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/.
 
 version.h:
                (echo 'static char const PKGVERSION[]="($(PACKAGE)) ";' && \
@@ -376,11 +383,16 @@
                cp yearistype.sh yearistype
                chmod +x yearistype
 
+leapseconds:   leapseconds.awk leap-seconds.list
+               $(AWK) -f leapseconds.awk leap-seconds.list >$@
+
 posix_only:    zic $(TDATA)
-               $(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L /dev/null $(TDATA)
+               $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
+                       -L /dev/null $(TDATA)
 
 right_only:    zic leapseconds $(TDATA)
-               $(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L leapseconds $(TDATA)
+               $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) \
+                       -L leapseconds $(TDATA)
 
 # In earlier versions of this makefile, the other two directories were
 # subdirectories of $(TZDIR).  However, this led to configuration errors.
@@ -391,19 +403,26 @@
 # Therefore, the other two directories are now siblings of $(TZDIR).
 # You must replace all of $(TZDIR) to switch from not using leap seconds
 # to using them, or vice versa.
-other_two:     zic leapseconds $(TDATA)
-               $(ZIC) -y $(YEARISTYPE) -d $(TZDIR)-posix -L /dev/null $(TDATA)
-               $(ZIC) -y $(YEARISTYPE) \
-                       -d $(TZDIR)-leaps -L leapseconds $(TDATA)
+right_posix:   right_only leapseconds
+               rm -fr $(DESTDIR)$(TZDIR)-leaps
+               ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-leaps || \
+                 $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-leaps \
+                       -L leapseconds $(TDATA)
+               $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-posix \
+                       -L /dev/null $(TDATA)
 
-posix_right:   posix_only other_two
-
-right_posix:   right_only other_two
+posix_right:   posix_only leapseconds
+               rm -fr $(DESTDIR)$(TZDIR)-posix
+               ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-posix || \
+                 $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-posix \
+                       -L /dev/null $(TDATA)
+               $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR)-leaps \
+                       -L leapseconds $(TDATA)
 
 zones:         $(REDO)
 
-$(TZLIB):      $(LIBOBJS)
-               -mkdir $(TOPDIR) $(LIBDIR)
+$(DESTDIR)$(TZLIB): $(LIBOBJS)
+               -mkdir -p $(DESTDIR)$(TOPDIR) $(DESTDIR)$(LIBDIR)
                ar ru $@ $(LIBOBJS)
                if [ -x /usr/ucb/ranlib ] || [ -x /usr/bin/ranlib ]; \
                        then ranlib $@ ; fi
@@ -435,7 +454,7 @@
 
 clean_misc:
                rm -f core *.o *.out \
-                 date tzselect version.h zdump zic yearistype
+                 date leapseconds tzselect version.h zdump zic yearistype
 clean:         clean_misc
                rm -f -r tzpublic
 
@@ -535,7 +554,7 @@
 
 typecheck:
                make clean
-               for i in "long long" unsigned double; \
+               for i in "long long" unsigned; \
                do \
                        make CFLAGS="-DTYPECHECK -D__time_t_defined -D_TIME_T \"-Dtime_t=$$i\"" ; \
                        ./zdump -v Europe/Rome ; \
diff -r a5fc941e765f -r 612bf9308578 lib/libc/time/Theory
--- a/lib/libc/time/Theory      Fri Sep 20 17:51:04 2013 +0000
+++ b/lib/libc/time/Theory      Fri Sep 20 19:06:54 2013 +0000
@@ -12,16 +12,13 @@
 
 ----- Time and date functions -----
 
-These time and date functions are upwards compatible with POSIX,
+These time and date functions are upwards compatible with those of POSIX,
 an international standard for UNIX-like systems.
 As of this writing, the current edition of POSIX is:
 
-  Standard for Information technology
-  -- Portable Operating System Interface (POSIX (R))
-  -- System Interfaces
-  IEEE Std 1003.1, 2004 Edition
-  <http://www.opengroup.org/online-pubs?DOC=7999959899>
-  <http://www.opengroup.org/pubs/catalog/t041.htm>
+  The Open Group Base Specifications Issue 7
+  IEEE Std 1003.1, 2013 Edition
+  <http://pubs.opengroup.org/onlinepubs/9699919799/>
 
 POSIX has the following properties and limitations.
 
@@ -34,7 +31,7 @@
 
        The POSIX TZ string takes the following form:
 
-               stdoffset[dst[offset],date[/time],date[/time]]
+               stdoffset[dst[offset][,date[/time],date[/time]]]
 
        where:
 
@@ -45,15 +42,17 @@
                in a quoted form like "<UTC+10>"; this allows
                "+" and "-" in the names.
        offset
-               is of the form `[-]hh:[mm[:ss]]' and specifies the
-               offset west of UTC.  The default DST offset is one hour
-               ahead of standard time.
+               is of the form '[+-]hh:[mm[:ss]]' and specifies the
+               offset west of UT.  'hh' may be a single digit; 0<=hh<=24.
+               The default DST offset is one hour ahead of standard time.
        date[/time],date[/time]
                specifies the beginning and end of DST.  If this is absent,
                the system supplies its own rules for DST, and these can
                differ from year to year; typically US DST rules are used.
        time
-               takes the form `hh:[mm[:ss]]' and defaults to 02:00.
+               takes the form 'hh:[mm[:ss]]' and defaults to 02:00.
+               This is the same format as the offset, except that a
+               leading '+' or '-' is not allowed.
        date
                takes one of the following forms:
                Jn (1<=n<=365)
@@ -63,8 +62,10 @@
                Mm.n.d (0[Sunday]<=d<=6[Saturday], 1<=n<=5, 1<=m<=12)
                        for the dth day of week n of month m of the year,
                        where week 1 is the first week in which day d appears,
-                       and `5' stands for the last week in which day d appears
+                       and '5' stands for the last week in which day d appears
                        (which may be either the 4th or 5th week).
+                       Typically, this is the only useful form;
+                       the n and Jn forms are rarely used.
 
        Here is an example POSIX TZ string, for US Pacific time using rules
        appropriate from 1987 through 2006:
@@ -95,6 +96,19 @@
 
 *      POSIX requires that systems ignore leap seconds.
 
+*      The tz code attempts attempts to support all the time_t implementations
+       allowed by POSIX.  The time_t type represents a nonnegative count of
+       seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds.
+       In practice, time_t is usually a signed 64- or 32-bit integer; 32-bit
+       signed time_t values stop working after 2038-01-19 03:14:07 UTC, so
+       new implementations these days typically use a signed 64-bit integer.
+       Unsigned 32-bit integers are used on one or two platforms,
+       and 36-bit integers are also used occasionally.
+       Although earlier POSIX versions allowed time_t to be a
+       floating-point type, this was not supported by any practical
+       systems, and POSIX.1-2013 and the tz code both require time_t
+       to be an integer type.
+
 These are the extensions that have been made to the POSIX functions:
 
 *      The "TZ" environment variable is used in generating the name of a file
@@ -146,6 +160,8 @@
        environment variable; portable applications should not, however, rely
        on this behavior since it's not the way SVR2 systems behave.)
 
+*      Negative time_t values are supported, on systems where time_t is signed.
+



Home | Main Index | Thread Index | Old Index