From cf47161082bf03ed0113f86cd1f110b4b2866aa9 Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 25 Jan 2018 22:48:42 +0000 Subject: [PATCH] Merge tzcode2018c [ changelog with changes to tzdata sections removed ] Release 2018c - 2018-01-22 23:00:44 -0800 Changes to build procedure The build procedure now works around mawk 1.3.3's lack of support for character class expressions. (Problem reported by Ohyama.) Release 2018b - 2018-01-17 23:24:48 -0800 Changes to build procedure The distribution now contains the file 'pacificnew' again. This file was inadvertantly omitted in the 2018a distribution. (Problem reported by Matias Fonzo.) Release 2018a - 2018-01-12 22:29:21 -0800 Changes to build procedure The default installation locations have been changed to mostly match Debian circa 2017, instead of being designed as an add-on to 4.3BSD circa 1986. This affects the Makefile macros TOPDIR, TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR, USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor locations more precisely. (This responds to suggestions from Brian Inglis and from Steve Summit.) The default installation procedure no longer creates the backward-compatibility link US/Pacific-New, which causes confusion during user setup (e.g., see Debian bug 815200). Use 'make BACKWARD="backward pacificnew"' to create the link anyway, for now. Eventually we plan to remove the link entirely. tzdata.zi now contains a version-number comment. (Suggested by Tom Lane.) The Makefile now quotes values like BACKWARD more carefully when passing them to the shell. (Problem reported by Zefram.) Builders no longer need to specify -DHAVE_SNPRINTF on platforms that have snprintf and use pre-C99 compilers. (Problem reported by Jon Skeet.) Changes to code zic has a new option -t FILE that specifies the location of the file that determines local time when TZ is unset. The default for this location can be configured via the new TZDEFAULT makefile macro, which defaults to /etc/localtime. Diagnostics and commentary now distinguish UT from UTC more carefully; see theory.html for more information about UT vs UTC. zic has been ported to GCC 8's -Wstringop-truncation option. (Problem reported by Martin Sebor.) Changes to documentation and commentary The zic man page now documents the longstanding behavior that times and years can be out of the usual range, with negative times counting backwards from midnight and with year 0 preceding year 1. (Problem reported by Michael Deckers.) The theory.html file now mentions the POSIX limit of six chars per abbreviation, and lists alphabetic abbreviations used. The files tz-art.htm and tz-link.htm have been renamed to tz-art.html and tz-link.html, respectively, for consistency with other file names and to simplify web server configuration. --- lib/libc/time/Makefile | 181 ++++++++++++++++++++++------------- lib/libc/time/NEWS | 166 +++++++++++++++++++++++++++++--- lib/libc/time/README | 4 +- lib/libc/time/ctime.3 | 8 +- lib/libc/time/localtime.c | 6 +- lib/libc/time/theory.html | 146 ++++++++++++++++++++-------- lib/libc/time/tz-how-to.html | 2 +- lib/libc/time/tzselect.8 | 4 +- lib/libc/time/tzselect.ksh | 8 +- lib/libc/time/tzset.3 | 26 ++--- lib/libc/time/version | 2 +- lib/libc/time/zdump.c | 57 +++++------ lib/libc/time/zic.8 | 145 +++++++++++++++++++--------- lib/libc/time/zic.c | 31 ++++-- 14 files changed, 553 insertions(+), 233 deletions(-) diff --git a/lib/libc/time/Makefile b/lib/libc/time/Makefile index c92edc064084..4f448d2b49c6 100644 --- a/lib/libc/time/Makefile +++ b/lib/libc/time/Makefile @@ -42,36 +42,63 @@ POSIXRULES= America/New_York # Also see TZDEFRULESTRING below, which takes effect only # if the time zone files cannot be accessed. -# Everything gets put in subdirectories of. . . -TOPDIR= /usr/local +# Installation locations. +# +# The defaults are suitable for Debian, except that if REDO is +# posix_right or right_posix then files that Debian puts under +# /usr/share/zoneinfo/posix and /usr/share/zoneinfo/right are instead +# put under /usr/share/zoneinfo-posix and /usr/share/zoneinfo-leaps, +# respectively. Problems with the Debian approach are discussed in +# the commentary for the right_posix rule (below). + +# Destination directory, which can be used for staging. +# 'make DESTDIR=/stage install' installs under /stage (e.g., to +# /stage/etc/localtime instead of to /etc/localtime). Files under +# /stage are not intended to work as-is, but can be copied by hand to +# the root directory later. If DESTDIR is empty, 'make install' does +# not stage, but installs directly into production locations. +DESTDIR = + +# Everything is installed into subdirectories of TOPDIR, and used there. +# TOPDIR should be empty (meaning the root directory), +# or a directory name that does not end in "/". +# TOPDIR should be empty or an absolute name unless you're just testing. +TOPDIR = + +# The default local time zone is taken from the file TZDEFAULT. +TZDEFAULT = $(TOPDIR)/etc/localtime + +# The subdirectory containing installed program and data files, and +# likewise for installed files that can be shared among architectures. +# These should be relative file names. +USRDIR = usr +USRSHAREDIR = $(USRDIR)/share # "Compiled" time zone information is placed in the "TZDIR" directory # (and subdirectories). -# Use an absolute path name for TZDIR unless you're just testing the software. # TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty. - TZDIR_BASENAME= zoneinfo -TZDIR= $(TOPDIR)/etc/$(TZDIR_BASENAME) +TZDIR = $(TOPDIR)/$(USRSHAREDIR)/$(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 +# The "tzselect" and (if you do "make INSTALL") "date" commands go in: +BINDIR = $(TOPDIR)/$(USRDIR)/bin -# The "tzselect", "zic", and "zdump" commands get installed in. . . +# The "zdump" command goes in: +ZDUMPDIR = $(BINDIR) -ETCDIR= $(TOPDIR)/etc - -# If you "make INSTALL", the "date" command gets installed in. . . - -BINDIR= $(TOPDIR)/bin +# The "zic" command goes in: +ZICDIR = $(TOPDIR)/$(USRDIR)/sbin # Manual pages go in subdirectories of. . . - -MANDIR= $(TOPDIR)/man +MANDIR = $(TOPDIR)/$(USRSHAREDIR)/man # Library functions are put in an archive in LIBDIR. +LIBDIR = $(TOPDIR)/$(USRDIR)/lib -LIBDIR= $(TOPDIR)/lib + +# 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 # If you want only POSIX time, with time values interpreted as # seconds since the epoch (not counting leap seconds), use @@ -105,11 +132,14 @@ REDO= posix_right TZDATA_TEXT= leapseconds tzdata.zi # For backward-compatibility links for old zone names, use +# BACKWARD= backward +# If you also want the link US/Pacific-New, even though it is confusing +# and is planned to be removed from the database eventually, use # BACKWARD= backward pacificnew # To omit these links, use # BACKWARD= -BACKWARD= backward pacificnew +BACKWARD= backward # If you want out-of-scope and often-wrong data from the file 'backzone', use # PACKRATDATA= backzone @@ -313,7 +343,7 @@ ZFLAGS= # How to use zic to install tz binary files. -ZIC_INSTALL= $(ZIC) -d $(DESTDIR)$(TZDIR) $(LEAPSECONDS) +ZIC_INSTALL= $(ZIC) -d '$(DESTDIR)$(TZDIR)' $(LEAPSECONDS) # The name of a Posix-compliant 'awk' on your system. AWK= awk @@ -341,8 +371,8 @@ SGML_CATALOG_FILES= \ VALIDATE = nsgmls VALIDATE_FLAGS = -s -B -wall -wno-unused-param VALIDATE_ENV = \ - SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) \ - SGML_SEARCH_PATH=$(SGML_SEARCH_PATH) \ + SGML_CATALOG_FILES='$(SGML_CATALOG_FILES)' \ + SGML_SEARCH_PATH='$(SGML_SEARCH_PATH)' \ SP_CHARSET_FIXED=YES \ SP_ENCODING=UTF-8 @@ -396,7 +426,7 @@ GZIPFLAGS= -9n #MAKE= make cc= cc -CC= $(cc) -DTZDIR=\"$(TZDIR)\" +CC= $(cc) -DTZDIR='"$(TZDIR)"' AR= ar @@ -421,18 +451,19 @@ MANTXTS= newctime.3.txt newstrftime.3.txt newtzset.3.txt \ date.1.txt COMMON= calendars CONTRIBUTING LICENSE Makefile \ NEWS README theory.html version -WEB_PAGES= tz-art.htm tz-how-to.html tz-link.htm +WEB_PAGES= tz-art.html tz-how-to.html tz-link.html DOCS= $(MANS) date.1 $(MANTXTS) $(WEB_PAGES) PRIMARY_YDATA= africa antarctica asia australasia \ europe northamerica southamerica -YDATA= $(PRIMARY_YDATA) etcetera $(BACKWARD) +YDATA= $(PRIMARY_YDATA) etcetera NDATA= systemv factory -TDATA= $(YDATA) $(NDATA) +TDATA_TO_CHECK= $(YDATA) $(NDATA) backward pacificnew +TDATA= $(YDATA) $(NDATA) $(BACKWARD) ZONETABLES= zone1970.tab zone.tab TABDATA= iso3166.tab $(TZDATA_TEXT) $(ZONETABLES) LEAP_DEPS= leapseconds.awk leap-seconds.list -TZDATA_ZI_DEPS= zishrink.awk $(TDATA) $(PACKRATDATA) -DATA= $(YDATA) $(NDATA) backzone iso3166.tab leap-seconds.list \ +TZDATA_ZI_DEPS= zishrink.awk version $(TDATA) $(PACKRATDATA) +DATA= $(TDATA_TO_CHECK) backzone iso3166.tab leap-seconds.list \ leapseconds yearistype.sh $(ZONETABLES) AWK_SCRIPTS= checklinks.awk checktab.awk leapseconds.awk zishrink.awk MISC= $(AWK_SCRIPTS) zoneinfo2tdf.pl @@ -457,7 +488,7 @@ VERSION_DEPS= \ newctime.3 newstrftime.3 newtzset.3 northamerica \ pacificnew private.h \ southamerica strftime.c systemv theory.html \ - time2posix.3 tz-art.htm tz-how-to.html tz-link.htm \ + time2posix.3 tz-art.html tz-how-to.html tz-link.html \ tzfile.5 tzfile.h tzselect.8 tzselect.ksh \ workman.sh yearistype.sh \ zdump.8 zdump.c zic.8 zic.c \ @@ -473,35 +504,41 @@ all: tzselect yearistype zic zdump libtz.a $(TABDATA) ALL: all date $(ENCHILADA) install: all $(DATA) $(REDO) $(MANS) - mkdir -p $(DESTDIR)$(ETCDIR) $(DESTDIR)$(TZDIR) \ - $(DESTDIR)$(LIBDIR) \ - $(DESTDIR)$(MANDIR)/man3 $(DESTDIR)$(MANDIR)/man5 \ - $(DESTDIR)$(MANDIR)/man8 - $(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES) - cp -f $(TABDATA) $(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/. + mkdir -p '$(DESTDIR)$(BINDIR)' \ + '$(DESTDIR)$(ZDUMPDIR)' '$(DESTDIR)$(ZICDIR)' \ + '$(DESTDIR)$(LIBDIR)' \ + '$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \ + '$(DESTDIR)$(MANDIR)/man8' + $(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES) \ + -t '$(DESTDIR)$(TZDEFAULT)' + cp -f $(TABDATA) '$(DESTDIR)$(TZDIR)/.' + cp tzselect '$(DESTDIR)$(BINDIR)/.' + cp zdump '$(DESTDIR)$(ZDUMPDIR)/.' + cp zic '$(DESTDIR)$(ZICDIR)/.' + 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 -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1 - cp date $(DESTDIR)$(BINDIR)/. - cp -f date.1 $(DESTDIR)$(MANDIR)/man1/. + mkdir -p '$(DESTDIR)$(BINDIR)' '$(DESTDIR)$(MANDIR)/man1' + cp date '$(DESTDIR)$(BINDIR)/.' + cp -f date.1 '$(DESTDIR)$(MANDIR)/man1/.' version: $(VERSION_DEPS) { (type git) >/dev/null 2>&1 && \ V=`git describe --match '[0-9][0-9][0-9][0-9][a-z]*' \ --abbrev=7 --dirty` || \ - V=$(VERSION); } && \ + V='$(VERSION)'; } && \ printf '%s\n' "$$V" >$@.out mv $@.out $@ # This file can be tailored by setting BACKWARD, PACKRATDATA, etc. tzdata.zi: $(TZDATA_ZI_DEPS) - LC_ALL=C $(AWK) -f zishrink.awk $(TDATA) $(PACKRATDATA) >$@.out + version=`sed 1q version` && \ + LC_ALL=C $(AWK) -v version="$$version" -f zishrink.awk \ + $(TDATA) $(PACKRATDATA) >$@.out mv $@.out $@ version.h: version @@ -529,12 +566,13 @@ leapseconds: $(LEAP_DEPS) # Arguments to pass to submakes of install_data. # They can be overridden by later submake arguments. INSTALLARGS = \ - BACKWARD=$(BACKWARD) \ - DESTDIR=$(DESTDIR) \ + BACKWARD='$(BACKWARD)' \ + DESTDIR='$(DESTDIR)' \ LEAPSECONDS='$(LEAPSECONDS)' \ PACKRATDATA='$(PACKRATDATA)' \ - TZDIR=$(TZDIR) \ - YEARISTYPE=$(YEARISTYPE) \ + TZDEFAULT='$(TZDEFAULT)' \ + TZDIR='$(TZDIR)' \ + YEARISTYPE='$(YEARISTYPE)' \ ZIC='$(ZIC)' # 'make install_data' installs one set of tz binary files. @@ -558,16 +596,16 @@ right_only: # You must replace all of $(TZDIR) to switch from not using leap seconds # to using them, or vice versa. right_posix: right_only - rm -fr $(DESTDIR)$(TZDIR)-leaps - ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-leaps || \ - $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-leaps right_only - $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-posix posix_only + rm -fr '$(DESTDIR)$(TZDIR)-leaps' + ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-leaps' || \ + $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only + $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only posix_right: posix_only - rm -fr $(DESTDIR)$(TZDIR)-posix - ln -s $(TZDIR_BASENAME) $(DESTDIR)$(TZDIR)-posix || \ - $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-posix posix_only - $(MAKE) $(INSTALLARGS) TZDIR=$(TZDIR)-leaps right_only + rm -fr '$(DESTDIR)$(TZDIR)-posix' + ln -s '$(TZDIR_BASENAME)' '$(DESTDIR)$(TZDIR)-posix' || \ + $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-posix' posix_only + $(MAKE) $(INSTALLARGS) TZDIR='$(TZDIR)-leaps' right_only # This obsolescent rule is present for backwards compatibility with # tz releases 2014g through 2015g. It should go away eventually. @@ -633,7 +671,7 @@ check_character_set: $(ENCHILADA) $(MISC) $(SOURCES) $(WEB_PAGES) \ CONTRIBUTING LICENSE Makefile README \ version tzdata.zi && \ - ! grep -Env $(SAFE_SHARP_LINE) $(TDATA) backzone \ + ! grep -Env $(SAFE_SHARP_LINE) $(TDATA_TO_CHECK) backzone \ leapseconds yearistype.sh zone.tab && \ ! grep -Env $(OK_LINE) $(ENCHILADA); \ } @@ -641,14 +679,16 @@ check_character_set: $(ENCHILADA) check_white_space: $(ENCHILADA) patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \ ! grep -En "$$pat" $(ENCHILADA) - ! grep -n '[[:space:]]$$' $(ENCHILADA) + ! grep -n '[[:space:]]$$' \ + $$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list) PRECEDES_FILE_NAME = ^(Zone|Link[[:space:]]+[^[:space:]]+)[[:space:]]+ FILE_NAME_COMPONENT_TOO_LONG = \ $(PRECEDES_FILE_NAME)[^[:space:]]*[^/[:space:]]{15} -check_name_lengths: $(TDATA) backzone - ! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' $(TDATA) backzone +check_name_lengths: $(TDATA_TO_CHECK) backzone + ! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' \ + $(TDATA_TO_CHECK) backzone CHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; } @@ -662,8 +702,8 @@ check_sorted: backward backzone iso3166.tab zone.tab zone1970.tab $(AWK) '/^[^#]/ $(CHECK_CC_LIST)' zone1970.tab | \ LC_ALL=C sort -cu -check_links: checklinks.awk $(TDATA) - $(AWK) -f checklinks.awk $(TDATA) +check_links: checklinks.awk $(TDATA_TO_CHECK) + $(AWK) -f checklinks.awk $(TDATA_TO_CHECK) $(AWK) -f checklinks.awk tzdata.zi check_tables: checktab.awk $(PRIMARY_YDATA) $(ZONETABLES) @@ -764,12 +804,12 @@ set-timestamps.out: $(ENCHILADA) check_public: $(MAKE) maintainer-clean - $(MAKE) "CFLAGS=$(GCC_DEBUG_FLAGS)" ALL + $(MAKE) CFLAGS='$(GCC_DEBUG_FLAGS)' ALL mkdir -p public.dir - for i in $(TDATA) tzdata.zi; do \ + for i in $(TDATA_TO_CHECK) tzdata.zi; do \ $(zic) -v -d public.dir $$i 2>&1 || exit; \ done - $(zic) -v -d public.dir $(TDATA) + $(zic) -v -d public.dir $(TDATA_TO_CHECK) rm -fr public.dir # Check that the code works under various alternative @@ -790,8 +830,11 @@ check_time_t_alternatives: REDO='$(REDO)' \ install && \ diff $$quiet_option -r \ - time_t.dir/int64_t/etc/zoneinfo \ - time_t.dir/$$type/etc/zoneinfo && \ + time_t.dir/int64_t/etc \ + time_t.dir/$$type/etc && \ + diff $$quiet_option -r \ + time_t.dir/int64_t/usr/share \ + time_t.dir/$$type/usr/share && \ case $$type in \ int32_t) range=-2147483648,2147483647;; \ uint32_t) range=0,4294967296;; \ @@ -800,9 +843,9 @@ check_time_t_alternatives: *) range=-10000000000,10000000000;; \ esac && \ echo checking $$type zones ... && \ - time_t.dir/int64_t/etc/zdump -V -t $$range $$zones \ + time_t.dir/int64_t/usr/bin/zdump -V -t $$range $$zones \ >time_t.dir/int64_t.out && \ - time_t.dir/$$type/etc/zdump -V -t $$range $$zones \ + time_t.dir/$$type/usr/bin/zdump -V -t $$range $$zones \ >time_t.dir/$$type.out && \ diff -u time_t.dir/int64_t.out time_t.dir/$$type.out \ || exit; \ diff --git a/lib/libc/time/NEWS b/lib/libc/time/NEWS index bd2bec223a0b..2bd0aa84143f 100644 --- a/lib/libc/time/NEWS +++ b/lib/libc/time/NEWS @@ -1,5 +1,147 @@ News for the tz database +Release 2018c - 2018-01-22 23:00:44 -0800 + + Briefly: + Revert Irish changes that relied on negative DST offsets. + + Changes to tm_isdst + + Revert the 2018a change to Europe/Dublin. As before, this change + does not affect UT offsets or abbreviations; it affects only + whether timestamps are considered to be standard time or + daylight-saving time, as expressed in the tm_isdst flag of C's + struct tm type. This reversion is intended to be a temporary + workaround for problems discovered with downstream uses of + releases 2018a and 2018b, which implemented Irish time by using + negative DST offsets in the Eire rules of the 'europe' file. + Although negative DST offsets have been part of tzcode for many + years and are supported by many platforms, they were not + documented before 2018a and ICU and OpenJDK do not currently + support them. A mechanism to export data to platforms lacking + support for negative DST is planned to be developed before the + change is reapplied. (Problems reported by Deborah Goldsmith and + Stephen Colebourne.) + + Changes to past time stamps + + Japanese DST transitions (1948-1951) were Sundays at 00:00, not + Saturdays or Sundays at 02:00. (Thanks to Takayuki Nikai.) + + Changes to build procedure + + The build procedure now works around mawk 1.3.3's lack of support + for character class expressions. (Problem reported by Ohyama.) + + +Release 2018b - 2018-01-17 23:24:48 -0800 + + Briefly: + Fix a packaging problem in tz2018a, which was missing 'pacificnew'. + + Changes to build procedure + + The distribution now contains the file 'pacificnew' again. + This file was inadvertantly omitted in the 2018a distribution. + (Problem reported by Matias Fonzo.) + + +Release 2018a - 2018-01-12 22:29:21 -0800 + + Briefly: + São Tomé and Príncipe switched from +00 to +01. + Brazil's DST will now start on November's first Sunday. + Ireland's standard time is now in the summer, not the winter. + Use Debian-style installation locations, instead of 4.3BSD-style. + New zic option -t. + + Changes to past and future time stamps + + São Tomé and Príncipe switched from +00 to +01 on 2018-01-01 at + 01:00. (Thanks to Steffen Thorsen and Michael Deckers.) + + Changes to future time stamps + + Starting in 2018 southern Brazil will begin DST on November's + first Sunday instead of October's third Sunday. (Thanks to + Steffen Thorsen.) + + Changes to past time stamps + + A discrepancy of 4 s in timestamps before 1931 in South Sudan has + been corrected. The 'backzone' and 'zone.tab' files did not agree + with the 'africa' and 'zone1970.tab' files. (Problem reported by + Michael Deckers.) + + The abbreviation invented for Bolivia Summer Time (1931-2) is now + BST instead of BOST, to be more consistent with the convention + used for Latvian Summer Time (1918-9) and for British Summer Time. + + Changes to tm_isdst + + Change Europe/Dublin so that it observes Irish Standard Time (UT + +01) in summer and GMT (as negative daylight-saving) in winter, + instead of observing standard time (GMT) in winter and Irish + Summer Time (UT +01) in summer. This change does not affect UT + offsets or abbreviations; it affects only whether timestamps are + considered to be standard time or daylight-saving time, as + expressed in the tm_isdst flag of C's struct tm type. + (Discrepancy noted by Derick Rethans.) + + Changes to build procedure + + The default installation locations have been changed to mostly + match Debian circa 2017, instead of being designed as an add-on to + 4.3BSD circa 1986. This affects the Makefile macros TOPDIR, + TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR, + USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor + locations more precisely. (This responds to suggestions from + Brian Inglis and from Steve Summit.) + + The default installation procedure no longer creates the + backward-compatibility link US/Pacific-New, which causes + confusion during user setup (e.g., see Debian bug 815200). + Use 'make BACKWARD="backward pacificnew"' to create the link + anyway, for now. Eventually we plan to remove the link entirely. + + tzdata.zi now contains a version-number comment. + (Suggested by Tom Lane.) + + The Makefile now quotes values like BACKWARD more carefully when + passing them to the shell. (Problem reported by Zefram.) + + Builders no longer need to specify -DHAVE_SNPRINTF on platforms + that have snprintf and use pre-C99 compilers. (Problem reported + by Jon Skeet.) + + Changes to code + + zic has a new option -t FILE that specifies the location of the + file that determines local time when TZ is unset. The default for + this location can be configured via the new TZDEFAULT makefile + macro, which defaults to /etc/localtime. + + Diagnostics and commentary now distinguish UT from UTC more + carefully; see theory.html for more information about UT vs UTC. + + zic has been ported to GCC 8's -Wstringop-truncation option. + (Problem reported by Martin Sebor.) + + Changes to documentation and commentary + + The zic man page now documents the longstanding behavior that + times and years can be out of the usual range, with negative times + counting backwards from midnight and with year 0 preceding year 1. + (Problem reported by Michael Deckers.) + + The theory.html file now mentions the POSIX limit of six chars + per abbreviation, and lists alphabetic abbreviations used. + + The files tz-art.htm and tz-link.htm have been renamed to + tz-art.html and tz-link.html, respectively, for consistency with + other file names and to simplify web server configuration. + + Release 2017c - 2017-10-20 14:49:34 -0700 Briefly: @@ -895,8 +1037,8 @@ Release 2015f - 2015-08-10 18:06:56 -0700 (Thanks to Jon Skeet and Arthur David Olson.) Constraints on simultaneity are now documented. - The two characters '%z' in a zone format now stand for the UTC - offset, e.g., '-07' for seven hours behind UTC and '+0530' for + The two characters '%z' in a zone format now stand for the UT + offset, e.g., '-07' for seven hours behind UT and '+0530' for five hours and thirty minutes ahead. This better supports time zone abbreviations conforming to POSIX.1-2001 and later. @@ -1019,13 +1161,13 @@ Release 2015c - 2015-04-11 08:55:55 -0700 The spring 1988 transition was 1988-10-09, not 1988-10-02. The fall 1990 transition was 1990-03-11, not 1990-03-18. - Assume no UTC offset change for Pacific/Easter on 1890-01-01, + Assume no UT offset change for Pacific/Easter on 1890-01-01, and omit all transitions on Pacific/Easter from 1942 through 1946 since we have no data suggesting that they existed. One more zone has been turned into a link, as it differed from an existing zone only for older time stamps. As usual, - this change affects UTC offsets in pre-1970 time stamps only. + this change affects UT offsets in pre-1970 time stamps only. The zone's old contents have been moved to the 'backzone' file. The affected zone is America/Montreal. @@ -1055,7 +1197,7 @@ Release 2015b - 2015-03-19 23:28:11 -0700 Some more zones have been turned into links, when they differed from existing zones only for older time stamps. As usual, - these changes affect UTC offsets in pre-1970 time stamps only. + these changes affect UT offsets in pre-1970 time stamps only. Their old contents have been moved to the 'backzone' file. The affected zones are: America/Antigua, America/Cayman, Pacific/Midway, and Pacific/Saipan. @@ -1107,7 +1249,7 @@ Release 2015a - 2015-01-29 22:35:20 -0800 Some more zones have been turned into links, when they differed from existing zones only for older time stamps. As usual, - these changes affect UTC offsets in pre-1970 time stamps only. + these changes affect UT offsets in pre-1970 time stamps only. Their old contents have been moved to the 'backzone' file. The affected zones are: Asia/Aden, Asia/Bahrain, Asia/Kuwait, and Asia/Muscat. @@ -1154,7 +1296,7 @@ Release 2014j - 2014-11-10 17:37:11 -0800 Some more zones have been turned into links, when they differed from existing zones only for older time stamps. As usual, - these changes affect UTC offsets in pre-1970 time stamps only. + these changes affect UT offsets in pre-1970 time stamps only. Their old contents have been moved to the 'backzone' file. The affected zones are: Africa/Addis_Ababa, Africa/Asmara, Africa/Dar_es_Salaam, Africa/Djibouti, Africa/Kampala, @@ -1244,7 +1386,7 @@ Release 2014h - 2014-09-25 18:59:03 -0700 Some more zones have been turned into links, when they differed from existing zones only for older timestamps. As usual, - these changes affect UTC offsets in pre-1970 timestamps only. + these changes affect UT offsets in pre-1970 timestamps only. Their old contents have been moved to the 'backzone' file. The affected zones are: Africa/Blantyre, Africa/Bujumbura, Africa/Gaborone, Africa/Harare, Africa/Kigali, Africa/Lubumbashi, @@ -1329,7 +1471,7 @@ Release 2014g - 2014-08-28 12:31:23 -0700 Some more zones have been turned into links, when they differed from existing zones only for older timestamps. As usual, - these changes affect UTC offsets in pre-1970 timestamps only. + these changes affect UT offsets in pre-1970 timestamps only. Their old contents have been moved to the 'backzone' file. The affected zones are: Africa/Bangui, Africa/Brazzaville, Africa/Douala, Africa/Kinshasa, Africa/Libreville, Africa/Luanda, @@ -1479,7 +1621,7 @@ Release 2014f - 2014-08-05 17:42:36 -0700 standard and daylight saving time the abbreviations are AEST and AEDT instead of the former EST for both; similarly, ACST/ACDT, ACWST/ACWDT, and AWST/AWDT are now used instead of the former CST, CWST, and WST. - This change does not affect UTC offsets, only time zone abbreviations. + This change does not affect UT offsets, only time zone abbreviations. (Thanks to Rich Tibbett and many others.) Asia/Novokuznetsk shifts from NOVT to KRAT (remaining on UT +07) @@ -1516,8 +1658,8 @@ Release 2014f - 2014-08-05 17:42:36 -0700 Treindl sent helpful translations of two papers by Guo Qingsheng.) Some zones have been turned into links, when they differed from existing - zones only for older UTC offsets where data entries were likely invented. - These changes affect UTC offsets in pre-1970 timestamps only. This is + zones only for older UT offsets where data entries were likely invented. + These changes affect UT offsets in pre-1970 timestamps only. This is similar to the change in release 2013e, except this time for western Africa. The affected zones are: Africa/Bamako, Africa/Banjul, Africa/Conakry, Africa/Dakar, Africa/Freetown, Africa/Lome, diff --git a/lib/libc/time/README b/lib/libc/time/README index 471fdf90eaad..ab8e47b63efb 100644 --- a/lib/libc/time/README +++ b/lib/libc/time/README @@ -11,14 +11,14 @@ changes made by political bodies to time zone boundaries, UTC offsets, and daylight-saving rules. See or the -file tz-link.htm for how to acquire the code and data. Once acquired, +file tz-link.html for how to acquire the code and data. Once acquired, read the comments in the file 'Makefile' and make any changes needed to make things right for your system, especially if you are using some platform other than GNU/Linux. Then run the following commands, substituting your desired installation directory for "$HOME/tzdir": make TOPDIR=$HOME/tzdir install - $HOME/tzdir/etc/zdump -v America/Los_Angeles + $HOME/tzdir/usr/bin/zdump -v America/Los_Angeles Historical local time information has been included here to: diff --git a/lib/libc/time/ctime.3 b/lib/libc/time/ctime.3 index 6e1242f36d24..447004cb7991 100644 --- a/lib/libc/time/ctime.3 +++ b/lib/libc/time/ctime.3 @@ -1,8 +1,8 @@ -.\" $NetBSD: ctime.3,v 1.55 2017/10/24 17:38:17 christos Exp $ +.\" $NetBSD: ctime.3,v 1.56 2018/01/25 22:48:42 christos Exp $ .\" .\" XXX: License missing? .\" -.Dd October 24, 2017 +.Dd January 25, 2018 .Dt CTIME 3 .Os .Sh NAME @@ -163,7 +163,7 @@ If .Fa zone is .Dv NULL , -UTC is used; otherwise, +UT is used; otherwise, .Fa zone should have been allocated by .Fn tzalloc @@ -444,6 +444,8 @@ function returns string containing the name of the timezone given in local time zone file .It Pa /usr/share/zoneinfo time zone information directory +.\" .It Pa usr/share/zoneinfo/localtime +.\" local time zone file .It Pa /usr/share/zoneinfo/posixrules used with POSIX-style TZ's .It Pa /usr/share/zoneinfo/GMT diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index 294912fead80..cf4d2b4f9a3e 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -1,4 +1,4 @@ -/* $NetBSD: localtime.c,v 1.110 2017/10/27 08:43:11 kre Exp $ */ +/* $NetBSD: localtime.c,v 1.111 2018/01/25 22:48:42 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.110 2017/10/27 08:43:11 kre Exp $"); +__RCSID("$NetBSD: localtime.c,v 1.111 2018/01/25 22:48:42 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -2116,7 +2116,7 @@ again: && ((/*CONSTCOND*/BIGGEST (INT_FAST32_MIN, LONG_MIN) + yourtm.TM_GMTOFF) <= mytm.TM_GMTOFF)))) { - /* MYTM matches YOURTM except with the wrong UTC offset. + /* MYTM matches YOURTM except with the wrong UT offset. YOURTM.TM_GMTOFF is plausible, so try it instead. It's OK if YOURTM.TM_GMTOFF contains uninitialized data, since the guess gets checked. */ diff --git a/lib/libc/time/theory.html b/lib/libc/time/theory.html index 965135d7e541..ff85f537b4e6 100644 --- a/lib/libc/time/theory.html +++ b/lib/libc/time/theory.html @@ -52,6 +52,10 @@ However, the database is not designed for and does not suffice for applications requiring accurate handling of all past times everywhere, as it would take far too much effort and guesswork to record all details of pre-1970 civil timekeeping. +Athough some information outside the scope of the database is +collected in a file backzone that is distributed along +with the database proper, this file is less reliable and does not +necessarily follow database guidelines.

@@ -240,7 +244,7 @@ to name time zone rules. It is intended to be an exhaustive list of names for geographic regions as described above; this is a subset of the names in the data. Although a 'zone1970.tab' location's longitude -corresponds to its LMT offset with one hour for every 15 degrees east +corresponds to its LMT offset with one hour for every 15° east longitude, this relationship is not exact.

@@ -279,7 +283,7 @@ Here are the general rules used for choosing time zone abbreviations, in decreasing order of importance: - [The remaining guidelines predate the introduction of %z. - They are problematic as they mean tz data entries invent - notation rather than record it. These guidelines are now - deprecated and the plan is to gradually move to %z for - inhabited locations and to "-00" for uninhabited locations.] -

Application writers should note that these abbreviations are ambiguous -in practice: e.g. 'CST' has a different meaning in China than -it does in the United States. In new applications, it's often better -to use numeric UT offsets like '-0600' instead of time zone -abbreviations like 'CST'; this avoids the ambiguity. +in practice: e.g., 'CST' means one thing in China and something else +in North America, and 'IST' can refer to time in India, Ireland or +Israel. To avoid ambiguity, use numeric UT offsets like +'-0600' instead of time zone abbreviations like 'CST'.

@@ -388,7 +450,7 @@ abbreviations like 'CST'; this avoids the ambiguity.

Accuracy of the tz database

The tz database is not authoritative, and it surely has errors. -Corrections are welcome and encouraged; see the file CONTRIBUTING. +Corrections are welcome and encouraged; see the file CONTRIBUTING. Users requiring authoritative data should consult national standards bodies and the references cited in the database's comments.

@@ -598,7 +660,7 @@ POSIX has the following properties and limitations. and daylight saving time (DST) zone names. Starting with POSIX.1-2001, std and dst may also be - in a quoted form like '<UTC+10>'; this allows + in a quoted form like '<+09>'; this allows "+" and "-" in the names.
offset
@@ -646,7 +708,7 @@ POSIX has the following properties and limitations.
Here is an example POSIX TZ string for New Zealand after 2007. - It says that standard time (NZST) is 12 hours ahead of UTC, + It says that standard time (NZST) is 12 hours ahead of UT, and that daylight saving time (NZDT) is observed from September's last Sunday at 02:00 until April's first Sunday at 03:00: @@ -678,7 +740,7 @@ POSIX has the following properties and limitations. applications that an administrator wants used only at certain times – without regard to whether the user has fiddled the TZ environment - variable. While an administrator can "do everything in UTC" to get + variable. While an administrator can "do everything in UT" to get around the problem, doing so is inconvenient and precludes handling daylight saving time shifts - as might be required to limit phone calls to off-peak hours.) @@ -902,7 +964,7 @@ Interface changes in a release attempt to preserve compatibility with recent releases. For example, tz data files typically do not rely on recently-added zic features, so that users can run older zic versions to process newer data -files. Sources for time zone and daylight +files. Sources for time zone and daylight saving time data describes how releases are tagged and distributed.

@@ -1003,7 +1065,7 @@ Sources: Michael Allison and Robert Schmunk, "Technical Notes on Mars Solar Time as Adopted by the Mars24 Sunclock" -(2012-08-08). +(2015-06-30).
  • Jia-Rui Chong, diff --git a/lib/libc/time/tz-how-to.html b/lib/libc/time/tz-how-to.html index 6007c5ec7916..a54f54a9689e 100644 --- a/lib/libc/time/tz-how-to.html +++ b/lib/libc/time/tz-how-to.html @@ -12,7 +12,7 @@ Database Source Files

    by Bill Seymour

    This page uses the America/Chicago and Pacific/Honolulu zones as examples of how to infer -times of day from the tz database +times of day from the tz database source files. It might be helpful, but not absolutely necessary, for the reader to have already downloaded the latest release of the database and become familiar with the basic layout diff --git a/lib/libc/time/tzselect.8 b/lib/libc/time/tzselect.8 index 274a01eb2463..c1020cad2e16 100644 --- a/lib/libc/time/tzselect.8 +++ b/lib/libc/time/tzselect.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: tzselect.8,v 1.6 2014/08/15 11:04:07 christos Exp $ +.\" $NetBSD: tzselect.8,v 1.7 2018/01/25 22:48:42 christos Exp $ .\" .TH TZSELECT 8 .SH NAME @@ -90,7 +90,7 @@ program (default: .TP \f3TZDIR\fP Name of the directory containing time zone data files (default: -.BR /usr/local/etc/zoneinfo ). +.BR /usr/share/zoneinfo ). .SH FILES .TP \f2TZDIR\fP\f3/iso3166.tab\fP diff --git a/lib/libc/time/tzselect.ksh b/lib/libc/time/tzselect.ksh index d234a3c0f982..8ace3b8b65c4 100644 --- a/lib/libc/time/tzselect.ksh +++ b/lib/libc/time/tzselect.ksh @@ -1,6 +1,6 @@ #! /bin/bash # -# $NetBSD: tzselect.ksh,v 1.16 2017/10/24 17:38:17 christos Exp $ +# $NetBSD: tzselect.ksh,v 1.17 2018/01/25 22:48:42 christos Exp $ # PKGVERSION='(tzcode) ' TZVERSION=see_Makefile @@ -344,8 +344,10 @@ while while echo >&2 'Please enter the desired value' \ 'of the TZ environment variable.' - echo >&2 'For example, GST-10 is a zone named GST' \ - 'that is 10 hours ahead (east) of UTC.' + echo >&2 'For example, AEST-10 is a zone named AEST' \ + 'that is 10 hours' + echo >&2 'ahead (east) of Greenwich,' \ + 'with no daylight saving time.' read TZ $AWK -v TZ="$TZ" 'BEGIN { tzname = "(<[[:alnum:]+-]{3,}>|[[:alpha:]]{3,})" diff --git a/lib/libc/time/tzset.3 b/lib/libc/time/tzset.3 index 999dfdaec648..aa6a45e85485 100644 --- a/lib/libc/time/tzset.3 +++ b/lib/libc/time/tzset.3 @@ -1,5 +1,5 @@ -.\" $NetBSD: tzset.3,v 1.36 2017/07/03 21:32:50 wiz Exp $ -.Dd October 6, 2016 +.\" $NetBSD: tzset.3,v 1.37 2018/01/25 22:48:42 christos Exp $ +.Dd January 25, 2018 .Dt TZSET 3 .Os .Sh NAME @@ -116,7 +116,7 @@ If the implied call to .Fn tzalloc fails, .Fn tzset -falls back on UTC. +falls back on Universal Time (UT). If .Ev TZ is @@ -131,7 +131,7 @@ is used by If .Ev TZ appears in the environment but its value is the empty string, -Universal Time (UT) is used, with the abbreviation +UT is used, with the abbreviation .Dq UTC and without leap second correction; please see .Xr ctime 3 . @@ -335,19 +335,19 @@ extensions to POSIX. .Bl -tag .It EST5 stands for US Eastern Standard -Time (EST), 5 hours behind UTC, without daylight saving. +Time (EST), 5 hours behind UT, without daylight saving. .It FJT\-12FJST,M11.1.0,M1.3.4/75 stands for Fiji Time (FJT) and Fiji Summer Time (FJST), 12 hours ahead -of UTC, springing forward on November's first Sunday at 02:00, and +of UT, springing forward on November's first Sunday at 02:00, and falling back on January's third Thursday at 75:00 (i.e., 03:00 on the first Sunday on or after January 18). .It IST\-2IDT,M3.4.4/26,M10.5.0 stands for Israel Standard Time (IST) and Israel Daylight Time (IDT), -2 hours ahead of UTC, springing forward on March's fourth +2 hours ahead of UT, springing forward on March's fourth Thursday at 26:00 (i.e., 02:00 on the first Friday on or after March 23), and falling back on October's last Sunday at 02:00. .It WART4WARST,J1/0,J365/25 -stands for Western Argentina Summer Time (WARST), 3 hours behind UTC. +stands for Western Argentina Summer Time (WARST), 3 hours behind UT. There is a dummy fall-back transition on December 31 at 25:00 daylight saving time (i.e., 24:00 standard time, equivalent to January 1 at 00:00 standard time), and a simultaneous spring-forward transition on @@ -357,9 +357,9 @@ all year and the initial is a placeholder. .It WGT3WGST,M3.5.0/\-2,M10.5.0/\-1 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 (\-02:00 local -time) and falling back on October's last Sunday at 01:00 UTC +Time (WGST), 3 hours behind UT, where clocks follow the EU rules of +springing forward on March's last Sunday at 01:00 UT (\-02:00 local +time) and falling back on October's last Sunday at 01:00 UT (\-01:00 local time). .El .Pp @@ -373,7 +373,7 @@ format file .Pa posixrules in .Pa /usr/share/zoneinfo -are used, with the standard and summer time offsets from UTC replaced +are used, with the standard and summer time offsets from UT replaced by those specified by the .Cm offset values in @@ -389,6 +389,8 @@ from the rest of the specification. local time zone file .It Pa /usr/share/zoneinfo time zone information directory +\" .It Pa /usr/share/zoneinfo/localtime +\" local time zone file .It Pa /usr/share/zoneinfo/posixrules used with POSIX-style TZ's .It Pa /usr/share/zoneinfo/GMT diff --git a/lib/libc/time/version b/lib/libc/time/version index 198e36de73e0..f6a71fe2f67f 100644 --- a/lib/libc/time/version +++ b/lib/libc/time/version @@ -1 +1 @@ -2017c +2018c diff --git a/lib/libc/time/zdump.c b/lib/libc/time/zdump.c index 9a875242ec24..20a1216ddf1b 100644 --- a/lib/libc/time/zdump.c +++ b/lib/libc/time/zdump.c @@ -1,4 +1,4 @@ -/* $NetBSD: zdump.c,v 1.47 2017/10/24 17:38:17 christos Exp $ */ +/* $NetBSD: zdump.c,v 1.48 2018/01/25 22:48:42 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 #ifndef lint -__RCSID("$NetBSD: zdump.c,v 1.47 2017/10/24 17:38:17 christos Exp $"); +__RCSID("$NetBSD: zdump.c,v 1.48 2018/01/25 22:48:42 christos Exp $"); #endif /* !defined lint */ /* @@ -268,7 +268,7 @@ tzfree(timezone_t env) } #endif /* ! USE_LOCALTIME_RZ */ -/* A UTC time zone, and its initializer. */ +/* A UT time zone, and its initializer. */ static timezone_t gmtz; static void gmtzinit(void) @@ -282,7 +282,7 @@ gmtzinit(void) } } -/* Convert *TP to UTC, storing the broken-down time into *TMP. +/* Convert *TP to UT, storing the broken-down time into *TMP. Return TMP if successful, NULL otherwise. This is like gmtime_r(TP, TMP), except typically faster if USE_LOCALTIME_RZ. */ static struct tm * @@ -552,6 +552,7 @@ main(int argc, char *argv[]) } if (t < cutlotime) t = cutlotime; + INITIALIZE (ab); tm_ok = my_localtime_rz(tz, &t, &tm) != NULL; if (tm_ok) { ab = saveabbr(&abbrev, &abbrevsize, &tm); @@ -567,11 +568,10 @@ main(int argc, char *argv[]) ? t + SECSPERDAY / 2 : cuthitime); struct tm *newtmp = localtime_rz(tz, &newt, &newtm); bool newtm_ok = newtmp != NULL; - if (! (tm_ok & newtm_ok - ? (delta(&newtm, &tm) == newt - t - && newtm.tm_isdst == tm.tm_isdst - && strcmp(abbr(&newtm), ab) == 0) - : tm_ok == newtm_ok)) { + if (tm_ok != newtm_ok + || (tm_ok && (delta(&newtm, &tm) != newt - t + || newtm.tm_isdst != tm.tm_isdst + || strcmp(abbr(&newtm), ab) != 0))) { newt = hunt(tz, argv[i], t, newt); newtmp = localtime_rz(tz, &newt, &newtm); newtm_ok = newtmp != NULL; @@ -733,8 +733,8 @@ adjusted_yday(struct tm const *a, struct tm const *b) } #endif -/* If A is the broken-down local time and B the broken-down UTC for - the same instant, return A's UTC offset in seconds, where positive +/* If A is the broken-down local time and B the broken-down UT for + the same instant, return A's UT offset in seconds, where positive offsets are east of Greenwich. On failure, return LONG_MIN. If T is nonnull, *T is the timestamp that corresponds to A; call @@ -798,12 +798,14 @@ show(timezone_t tz, char *zone, time_t t, bool v) abbrok(abbr(tmp), zone); } -#if !HAVE_SNPRINTF +#if HAVE_SNPRINTF +# define my_snprintf snprintf +#else # include /* A substitute for snprintf that is good enough for zdump. */ -static int -snprintf(char *s, size_t size, char const *format, ...) +static int ATTRIBUTE_FORMAT((printf, 3, 4)) +my_snprintf(char *s, size_t size, char const *format, ...) { int n; va_list args; @@ -842,16 +844,16 @@ format_local_time(char *buf, size_t size, struct tm const *tm) { int ss = tm->tm_sec, mm = tm->tm_min, hh = tm->tm_hour; return (ss - ? snprintf(buf, size, "%02d:%02d:%02d", hh, mm, ss) + ? my_snprintf(buf, size, "%02d:%02d:%02d", hh, mm, ss) : mm - ? snprintf(buf, size, "%02d:%02d", hh, mm) - : snprintf(buf, size, "%02d", hh)); + ? my_snprintf(buf, size, "%02d:%02d", hh, mm) + : my_snprintf(buf, size, "%02d", hh)); } -/* Store into BUF, of size SIZE, a formatted UTC offset for the +/* Store into BUF, of size SIZE, a formatted UT offset for the localtime *TM corresponding to time T. Use ISO 8601 format +HHMMSS, or -HHMMSS for timestamps west of Greenwich; use the - format -00 for unknown UTC offsets. If the hour needs more than + format -00 for unknown UT offsets. If the hour needs more than two digits to represent, extend the length of HH as needed. Otherwise, omit SS if SS is zero, and omit MM too if MM is also zero. @@ -880,10 +882,10 @@ format_utc_offset(char *buf, size_t size, struct tm const *tm, time_t t) mm = off / 60 % 60; hh = off / 60 / 60; return (ss || 100 <= hh - ? snprintf(buf, size, "%c%02ld%02d%02d", sign, hh, mm, ss) + ? my_snprintf(buf, size, "%c%02ld%02d%02d", sign, hh, mm, ss) : mm - ? snprintf(buf, size, "%c%02ld%02d", sign, hh, mm) - : snprintf(buf, size, "%c%02ld", sign, hh)); + ? my_snprintf(buf, size, "%c%02ld%02d", sign, hh, mm) + : my_snprintf(buf, size, "%c%02ld", sign, hh)); } /* Store into BUF (of size SIZE) a quoted string representation of P. @@ -926,7 +928,7 @@ format_quoted_string(char *buf, size_t size, char const *p) %f zone name %L local time as per format_local_time - %Q like "U\t%Z\tD" where U is the UTC offset as for format_utc_offset + %Q like "U\t%Z\tD" where U is the UT offset as for format_utc_offset and D is the isdst flag; except omit D if it is zero, omit %Z if it equals U, quote and escape %Z if it contains nonalphabetics, and omit any trailing tabs. */ @@ -986,15 +988,16 @@ istrftime(char *buf, size_t size, char const *time_fmt, for (abp = ab; is_alpha(*abp); abp++) continue; len = (!*abp && *ab - ? (size_t)snprintf(b, s, "%s", ab) + ? (size_t)my_snprintf(b, s, "%s", ab) : format_quoted_string(b, s, ab)); if (s <= len) return false; b += len, s -= len; } - formatted_len = (tm->tm_isdst - ? snprintf(b, s, &"\t\t%d"[show_abbr], tm->tm_isdst) - : 0); + formatted_len + = (tm->tm_isdst + ? my_snprintf(b, s, &"\t\t%d"[show_abbr], tm->tm_isdst) + : 0); } break; } diff --git a/lib/libc/time/zic.8 b/lib/libc/time/zic.8 index 72a59c52a2e4..0506b9691faa 100644 --- a/lib/libc/time/zic.8 +++ b/lib/libc/time/zic.8 @@ -1,5 +1,5 @@ -.\" $NetBSD: zic.8,v 1.27 2017/10/24 17:38:17 christos Exp $ -.Dd October 24, 2017 +.\" $NetBSD: zic.8,v 1.28 2018/01/25 22:48:42 christos Exp $ +.Dd January 25, 2018 .Dt ZIC 8 .Os .Sh NAME @@ -13,6 +13,7 @@ .Op Fl l Ar localtime .Op Fl p Ar posixrules .Op Fl s +.Op Fl t Ar file .Op Fl v .Op Fl y Ar command .Op Ar Filename ... @@ -52,35 +53,49 @@ will act as if the input contained a link line of the form Limit time values stored in output files to values that are the same whether they're taken to be signed or unsigned. You can use this option to generate SVVS-compatible files. +.It Fl t Ar file +When creating local time information, put the configuration link in +the named file rather than in the standard location. .It Fl v Be more verbose, and complain about the following situations: .Bl -dash -.It The input specifies a link to a link. -.It A year that appears in a data file is outside the range -.It A time of 24:00 or more appears in the input. +.It +The input specifies a link to a link. +.It +A year that appears in a data file is outside the range +of years representable by +.Xr time 2 +values. +.It +A time of 24:00 or more appears in the input. Pre-1998 versions of .Xr zic 8 prohibit 24:00, and pre-2007 versions prohibit times greater than 24:00. -.It A rule goes past the start or end of the month. +.It +A rule goes past the start or end of the month. Pre-2004 versions of .Xr zic 8 prohibit this. -.It The output file does not contain all the information about the +.It +The output file does not contain all the information about the long-term future of a zone, because the future cannot be summarized as an extended POSIX TZ string. For example, as of 2013 this problem occurs for Iran's daylight-saving rules for the predicted future, as these rules are based on the Iranian calendar, which cannot be represented. -.It The output contains data that may not be handled properly by client +.It +The output contains data that may not be handled properly by client code designed for older .Xr zic 8 output formats. These compatibility issues affect only time stamps before 1970 or after the start of 2038. -.It A time zone abbreviation has fewer than 3 characters. +.It +A time zone abbreviation has fewer than 3 characters. POSIX requires at least 3. -.It An output file name contains a byte that is not an ASCII letter, +.It +An output file name contains a byte that is not an ASCII letter, .Dq - , .Dq / , or @@ -90,6 +105,7 @@ or it contains a file name component that contains more than 14 bytes or that starts with .Dq - . .El +.El .Pp Input files should be text files, that is, they should be a series of zero or more lines, each ending in a newline byte and containing at @@ -99,7 +115,9 @@ bytes. The input text's encoding is typically UTF-8 or ASCII; it should have a unibyte representation for the POSIX Portable Character Set (PPCS) +.Rs .%U http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap06.html +.Re and the encoding's non-unibyte characters should consist entirely of non-PPCS bytes. Non-PPCS characters typically occur only in comments: @@ -137,22 +155,27 @@ A name can be abbreviated by omitting all but an initial prefix; any abbreviation must be unambiguous in context. .Pp A rule line has the form -.Dl Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +.Pp +.Dl Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +.Pp For example: +.Pp .Dl Rule US 1967 1973 \- Apr lastSun 2:00 1:00 D +.Pp The fields that make up a rule line are: -.Bl -tag -width "LETTER/S" -compact +.Bl -tag -width "LETTER/S" .It NAME Gives the (arbitrary) name of the set of rules this rule is part of. .It FROM Gives the first year in which the rule applies. -Any integer year can be supplied; the proleptic Gregorian calendar is assumed. +Any signed integer year can be supplied; the proleptic Gregorian calendar +is assumed, with year 0 preceding year 1. The word .Em minimum -(or an abbreviation) means the minimum year representable as an integer. +(or an abbreviation) means the indefinite past. The word .Em maximum -(or an abbreviation) means the maximum year representable as an integer. +(or an abbreviation) means the indefinite future. Rules can describe times that are not representable as time values, with the unrepresentable times ignored; this allows rules to be portable among hosts with differing time value types. @@ -181,6 +204,7 @@ Month names may be abbreviated. .It ON Gives the day on which the rule takes effect. Recognized forms include: +.Pp .Bl -tag -width lastSun -compact -offset indent .It 5 the fifth of the month @@ -193,6 +217,7 @@ first Sunday on or after the eighth .It Sun\*[Le]25 last Sunday on or before the 25th .El +.Pp Names of days of the week may be abbreviated or spelled out in full. A weekday name (e.g., .Dq Sunday ) @@ -207,18 +232,24 @@ field. .It AT Gives the time of day at which the rule takes effect. Recognized forms include: -.Bl -tag -width "1X28X14" -compact -offset indent +.Pp +.Bl -tag -width "01X28X14" -compact -offset indent .It 2 time in hours .It 2:00 time in hours and minutes +.It 01:28:14 +time in hours, minutes, and seconds .It 15:00 24-hour format time (for times after noon) -.It 1:28:14 -time in hours, minutes, and seconds +.It 260:00 +260 hours after 00:00 +.It \-2:30 +2.5 hours before 00:00 .It \- equivalent to 0 .El +.Pp where hour 0 is midnight at the start of the day, and hour 24 is midnight at the end of the day. Any of these forms may be followed by the letter @@ -249,10 +280,10 @@ This field has the same format as the .Em AT field (although, of course, the -.Em w -and -.Em s suffixes are not used). +Negative offsets are allowed; in Ireland, for example, daylight saving +time is observed in winter and has a negative offset relative to +Irish Standard Time. Only the sum of standard time and this amount matters; for example, .Nm does not distinguish a 10:30 standard time plus an 0:30 @@ -277,12 +308,15 @@ the variable part is null. .El .Pp A zone line has the form -.sp -.Dl Zone NAME GMTOFF RULES/SAVE FORMAT [UNTILYEAR [MONTH [DAY [TIME]]]] +.Pp +.Dl Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] +.Pp For example: -.Dl Zone Australia/Adelaide 9:30 Aus AC%sT 1971 Oct 31 2:00 +.Pp +.Dl Zone Asia/Amman 2:00 Jordan EE%sT 2017 Oct 27 1:00 +.Pp The fields that make up a zone line are: -.Bl -tag -width "RULES/SAVE" -compact +.Bl -tag -width "RULES/SAVE" .It NAME The name of the time zone. This is the name used in creating the time conversion information file for the @@ -301,8 +335,8 @@ and .Em SAVE fields of rule lines; begin the field with a minus sign if time must be subtracted from UT. -.It RULES/SAVE -The name of the rule(s) that apply in the time zone or, +.It RULES +The name of the rules that apply in the time zone or, alternatively, an amount of time to add to local standard time. If this field is .Em \&- @@ -318,7 +352,7 @@ is used to show where the of the time zone abbreviation goes. Alternately, a format can use the pair of characters .Em %z -+to stand for the UTC offset in the form ++to stand for the UT offset in the form .Em \(+- hh , .Em \(+- hhmm , or @@ -328,16 +362,16 @@ using the shortest form that does not lose information, where .Em mm , and .Em ss -are the hours, minutes, and seconds east (+) or west (\(mi) of UTC. +are the hours, minutes, and seconds east (+) or west (\(mi) of UT. Alternatively, a slash .Pq \&/ separates standard and daylight abbreviations. To conform to POSIX, a time zone abbreviation should contain only alphanumeric ASCII characters, "+" and "\*-". -.It UNTILYEAR [MONTH [DAY [TIME]]] +.It UNTIL The time at which the UT offset or the rule(s) change for a location. -It is specified as a year, a month, a day, and a time of day. +It takes the form of YEAR [MONTH [DAY [TIME]]]. If this is specified, the time zone information is generated from the given UT offset and rule change until the time specified, which is interpreted using @@ -345,7 +379,7 @@ the rules in effect just before the transition. The month, day, and time of day have the same format as the IN, ON, and AT fields of a rule; trailing fields can be omitted, and default to the earliest possible value for the missing fields. -.El +.Pp The next line must be a .Dq continuation line; this has the same form as a zone line except that the @@ -359,6 +393,7 @@ Continuation lines may contain .Em until information, just as zone lines do, indicating that the next line is a further continuation. +.El .Pp If a zone changes at the same instant that a rule would otherwise take effect in the earlier zone or continuation line, the rule is ignored. @@ -366,9 +401,13 @@ In a single zone it is an error if two rules take effect at the same instant, or if two zone changes take effect at the same instant. .Pp A link line has the form -.Dl Link TARGET LINK-NAME +.Pp +.Dl Link TARGET LINK-NAME +.Pp For example: +.Pp .Dl Link Europe/Istanbul Asia/Istanbul +.Pp The .Em TARGET field should appear as the @@ -388,9 +427,13 @@ define the same name, or if the source of one link line is the target of another. .Pp Lines in the file that describes leap seconds have the following form: +.Pp .Dl Leap YEAR MONTH DAY HH:MM:SS CORR R/S +.Pp For example: -.Dl Leap 1974 Dec 31 23:59:60 + S +.Pp +.Dl Leap 2016 Dec 31 23:59:60 + S +.Pp The .Em YEAR , .Em MONTH , @@ -418,12 +461,14 @@ or .Dq Rolling if the leap second time given by the other fields should be interpreted as local wall clock time. -.El .Sh EXTENDED EXAMPLE Here is an extended example of .Ic zic input, intended to illustrate many of its features. -.Bl -column -compact "# Rule" "Swiss" "FROM" "1995" "TYPE" "Oct" "lastSun" "1:00u" "SAVE" "LETTER/S" +In this example, the EU rules are for the European Union +and for its predecessor organization, the European Communities. +.Pp +.Bl -column -compact -offset indent "# Rule" "Swiss" "FROM" "1995" "TYPE" "Oct" "lastSun" "1:00u" "SAVE" "LETTER/S" .It # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S .It Rule Swiss 1941 1942 - May Mon>=1 1:00 1:00 S .It Rule Swiss 1941 1942 - Oct Mon>=1 2:00 0 - @@ -436,27 +481,29 @@ input, intended to illustrate many of its features. .It Rule EU 1996 max - Oct lastSun 1:00u 0 - .El .Pp -.Bl -column -compact "# Zone" "Europe/Zurich" "0:34:08" "RULES/SAVE" "FORMAT" "UNTIL" -.It # Zone NAME GMTOFF RULES/SAVE FORMAT UNTIL +.Bl -column -compact -offset indent "# Zone" "Europe/Zurich" "0:34:08" "RULES/SAVE" "FORMAT" "UNTIL" +.It # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] .It Zone Europe/Zurich 0:34:08 - LMT 1853 Jul 16 .It 0:29:44 - BMT 1894 Jun .It 1:00 Swiss CE%sT 1981 .It 1:00 EU CE%sT -.It Link Europe/Zurich Switzerland +.Pp +.El +.Bl -column -compact -offset indent "# Zone" "Europe/Zurich" "0:34:08" "RULES/SAVE" "FORMAT" "UNTIL" +.It Link Europe/Zurich Europe/Vaduz .El .Pp In this example, the zone is named Europe/Zurich but it has an alias -as Switzerland. +as Europe/Vaduz. This example says that Zurich was 34 minutes and 8 -seconds west of UT until 1853-07-16 at 00:00, when the legal offset +seconds east of UT until 1853-07-16 at 00:00, when the legal offset was changed to 7\(de\|26\(fm\|22.50\(sd; although this works out to 0:29:45.50, the input format cannot represent fractional seconds so it is rounded here. -After 1894-06-01 at 00:00 Swiss daylight saving rules -(defined with lines beginning with "Rule Swiss") apply, and the UT offset -became one hour. +After 1894-06-01 at 00:00 the UT offset became one hour +and Swiss daylight saving rules (defined with lines beginning with "Rule +Swiss") apply. From 1981 to the present, EU daylight saving rules have -applied, and the UTC offset has remained at one hour. .Pp In 1941 and 1942, daylight saving time applied from the first Monday in May at 01:00 to the first Monday in October at 02:00. @@ -497,8 +544,12 @@ This works around bugs in software that mishandles large negative time stamps. Call it sour grapes, but pre-Big-Bang time stamps are physically suspect anyway. The pre-Big-Bang cutoff time is approximate and may change in future versions. .Sh FILES -.Pa /usr/share/zoneinfo -- standard directory used for created files +.Bl -tag -width /usr/share/zoneinfo -compact +.It Pa /etc/localtime +default local time zone file +.It Pa /usr/share/zoneinfo +standard directory used for created files +.El .Sh SEE ALSO .Xr ctime 3 , .Xr tzfile 5 , diff --git a/lib/libc/time/zic.c b/lib/libc/time/zic.c index 9006a82dc432..41787ddbe774 100644 --- a/lib/libc/time/zic.c +++ b/lib/libc/time/zic.c @@ -1,4 +1,4 @@ -/* $NetBSD: zic.c,v 1.69 2017/10/24 17:38:17 christos Exp $ */ +/* $NetBSD: zic.c,v 1.70 2018/01/25 22:48:42 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 #ifndef lint -__RCSID("$NetBSD: zic.c,v 1.69 2017/10/24 17:38:17 christos Exp $"); +__RCSID("$NetBSD: zic.c,v 1.70 2018/01/25 22:48:42 christos Exp $"); #endif /* !defined lint */ #include "private.h" @@ -561,7 +561,7 @@ usage(FILE *stream, int status) fprintf(stream, _("%s: usage is %s [ --version ] [ --help ] [ -v ] \\\n" "\t[ -l localtime ] [ -p posixrules ] [ -d directory ] \\\n" - "\t[ -L leapseconds ] [ filename ... ]\n\n" + "\t[ -t localtime-link ] [ -L leapseconds ] [ filename ... ]\n\n" "Report bugs to %s.\n"), progname, progname, REPORT_BUGS_TO); if (status == EXIT_SUCCESS) @@ -593,6 +593,7 @@ static const char * psxrules; static const char * lcltime; static const char * directory; static const char * leapsec; +static const char * tzdefault; static const char * yitcommand; int @@ -625,7 +626,7 @@ main(int argc, char **argv) } else if (strcmp(argv[k], "--help") == 0) { usage(stdout, EXIT_SUCCESS); } - while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF && c != -1) + while ((c = getopt(argc, argv, "d:l:L:p:st:vy:")) != EOF && c != -1) switch (c) { default: usage(stderr, EXIT_FAILURE); @@ -659,6 +660,16 @@ _("%s: More than one -p option specified\n"), return EXIT_FAILURE; } break; + case 't': + if (tzdefault != NULL) { + fprintf(stderr, + _("%s: More than one -t option" + " specified\n"), + progname); + return EXIT_FAILURE; + } + tzdefault = optarg; + break; case 'y': if (yitcommand == NULL) { warning(_("-y is obsolescent")); @@ -691,6 +702,8 @@ _("%s: More than one -L option specified\n"), usage(stderr, EXIT_FAILURE); /* usage message by request */ if (directory == NULL) directory = TZDIR; + if (tzdefault == NULL) + tzdefault = TZDEFAULT; if (yitcommand == NULL) yitcommand = "yearistype"; @@ -727,7 +740,7 @@ _("%s: More than one -L option specified\n"), } if (lcltime != NULL) { eat(_("command line"), 1); - dolink(lcltime, TZDEFAULT, true); + dolink(lcltime, tzdefault, true); } if (psxrules != NULL) { eat(_("command line"), 1); @@ -1262,10 +1275,10 @@ inzone(char **fields, int nfields) error(_("wrong number of fields on Zone line")); return false; } - if (strcmp(fields[ZF_NAME], TZDEFAULT) == 0 && lcltime != NULL) { + if (lcltime != NULL && strcmp(fields[ZF_NAME], tzdefault) == 0) { error( _("\"Zone %s\" line and -l option are mutually exclusive"), - TZDEFAULT); + tzdefault); return false; } if (strcmp(fields[ZF_NAME], TZDEFRULES) == 0 && psxrules != NULL) { @@ -1976,7 +1989,7 @@ writezone(const char *const name, const char *const string, char version) } #define DO(field) fwrite(tzh.field, sizeof tzh.field, (size_t) 1, fp) tzh = tzh0; - strncpy(tzh.tzh_magic, TZ_MAGIC, sizeof tzh.tzh_magic); + memcpy(tzh.tzh_magic, TZ_MAGIC, sizeof tzh.tzh_magic); tzh.tzh_version[0] = version; convert(thistypecnt, tzh.tzh_ttisgmtcnt); convert(thistypecnt, tzh.tzh_ttisstdcnt); @@ -2071,7 +2084,7 @@ abbroffset(char *buf, zic_t offset) minutes = offset % MINSPERHOUR; offset /= MINSPERHOUR; if (100 <= offset) { - error(_("%%z UTC offset magnitude exceeds 99:59:59")); + error(_("%%z UT offset magnitude exceeds 99:59:59")); return "%z"; } else { char *p = buf;