Module Name:    src
Committed By:   christos
Date:           Thu Aug 13 11:21:18 UTC 2015

Modified Files:
        src/lib/libc/time: Makefile NEWS Theory difftime.c localtime.c
            private.h strftime.c tz-art.htm tz-link.htm zdump.c zic.8 zic.c

Log Message:
merge 2015f


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/time/Makefile
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/time/NEWS
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/time/Theory
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/time/difftime.c
cvs rdiff -u -r1.95 -r1.96 src/lib/libc/time/localtime.c
cvs rdiff -u -r1.42 -r1.43 src/lib/libc/time/private.h
cvs rdiff -u -r1.33 -r1.34 src/lib/libc/time/strftime.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/time/tz-art.htm
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/time/tz-link.htm
cvs rdiff -u -r1.41 -r1.42 src/lib/libc/time/zdump.c
cvs rdiff -u -r1.25 -r1.26 src/lib/libc/time/zic.8
cvs rdiff -u -r1.54 -r1.55 src/lib/libc/time/zic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/time/Makefile
diff -u src/lib/libc/time/Makefile:1.29 src/lib/libc/time/Makefile:1.30
--- src/lib/libc/time/Makefile:1.29	Sun Jun 21 12:06:51 2015
+++ src/lib/libc/time/Makefile	Thu Aug 13 07:21:18 2015
@@ -5,7 +5,7 @@
 PACKAGE=	tzcode
 
 # Version numbers of the code and data distributions.
-VERSION=	2015e
+VERSION=	2015f
 
 # Email address for bug reports.
 BUGEMAIL=	t...@iana.org
@@ -102,7 +102,6 @@ LDLIBS=
 
 # Add the following to the end of the "CFLAGS=" line as needed.
 #  -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c)
-#  -DHAVE_ADJTIME=0 if 'adjtime' does not exist (SVR0?)
 #  -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS)
 #  -DHAVE_GETTEXT=1 if 'gettext' works (GNU, Linux, Solaris); also see LDLIBS
 #  -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares
@@ -113,10 +112,6 @@ LDLIBS=
 #  -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
 #	This defaults to 1 if a working localtime_rz seems to be available.
 #	localtime_rz can make zdump significantly faster, but is nonstandard.
-#  -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)
-#  -DHAVE_SETTIMEOFDAY=3 if settimeofday ignores 2nd arg (4.4BSD)
 #  -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h"
 #  -DHAVE_STRFTIME_L=1 if <time.h> declares locale_t and strftime_l
 #	This defaults to 0 if _POSIX_VERSION < 200809, 1 otherwise.
@@ -126,7 +121,6 @@ LDLIBS=
 #  -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h"
 #  -DHAVE_TZSET=0 if your system lacks a tzset function
 #  -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
-#  -DHAVE_UTMPX_H=1 if your compiler has a "utmpx.h"
 #  -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
@@ -148,7 +142,7 @@ LDLIBS=
 #  -DZIC_MAX_ABBR_LEN_WO_WARN=3
 #	(or some other number) to set the maximum time zone abbreviation length
 #	that zic will accept without a warning (the default is 6)
-#  $(GCC_DEBUG_FLAGS) if you are using GCC and want lots of checking
+#  $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
 GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \
 	-Wall -Wextra \
 	-Wbad-function-cast -Wcast-align -Wdate-time \

Index: src/lib/libc/time/NEWS
diff -u src/lib/libc/time/NEWS:1.12 src/lib/libc/time/NEWS:1.13
--- src/lib/libc/time/NEWS:1.12	Sun Jun 21 12:06:51 2015
+++ src/lib/libc/time/NEWS	Thu Aug 13 07:21:18 2015
@@ -1,5 +1,71 @@
 News for the tz database
 
+Release 2015f - 2015-08-10 18:06:56 -0700
+
+  Changes affecting future time stamps
+
+    North Korea switches to +0830 on 2015-08-15.  (Thanks to Steffen Thorsen.)
+    The abbreviation remains "KST".  (Thanks to Robert Elz.)
+
+    Uruguay no longer observes DST.  (Thanks to Steffen Thorsen
+    and Pablo Camargo.)
+
+  Changes affecting past and future time stamps
+
+    Moldova starts and ends DST at 00:00 UTC, not at 01:00 UTC.
+    (Thanks to Roman Tudos.)
+
+  Changes affecting data format and code
+
+    zic's '-y YEARISTYPE' option is no longer documented.  The TYPE
+    field of a Rule line should now be '-'; the old values 'even',
+    'odd', 'uspres', 'nonpres', 'nonuspres' were already undocumented.
+    Although the implementation has not changed, these features do not
+    work in the default installation, they are not used in the data,
+    and they are now considered obsolescent.
+
+    zic now checks that two rules don't take effect at the same time.
+    (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
+    five hours and thirty minutes ahead.  This better supports time
+    zone abbreviations conforming to POSIX.1-2001 and later.
+
+  Changes affecting installed data files
+
+    Comments for America/Halifax and America/Glace_Bay have been improved.
+    (Thanks to Brian Inglis.)
+
+    Data entries have been simplified for Atlantic/Canary, Europe/Simferopol,
+    Europe/Sofia, and Europe/Tallinn.  This yields slightly smaller
+    installed data files for Europe/Simferopol and Europe/Tallinn.
+    It does not affect timestamps.  (Thanks to Howard Hinnant.)
+
+  Changes affecting code
+
+    zdump and zic no longer warn about valid time zone abbreviations
+    like '-05'.
+
+    Some Visual Studio 2013 warnings have been suppressed.
+    (Thanks to Kees Dekker.)
+
+    'date' no longer sets the time of day and its -a, -d, -n and -t
+    options have been removed.  Long obsolescent, the implementation
+    of these features had porting problems.  Builders no longer need
+    to configure HAVE_ADJTIME, HAVE_SETTIMEOFDAY, or HAVE_UTMPX_H.
+    (Thanks to Kees Dekker for pointing out the problem.)
+
+  Changes affecting documentation
+
+    The Theory file mentions naming issues earlier, as these seem to be
+    poorly publicized (thanks to Gilmore Davidson for reporting the problem).
+
+    tz-link.htm mentions Time Zone Database Parser (thanks to Howard Hinnant).
+
+    Mention that Herbert Samuel introduced the term "Summer Time".
+
 
 Release 2015e - 2015-06-13 10:56:02 -0700
 

Index: src/lib/libc/time/Theory
diff -u src/lib/libc/time/Theory:1.17 src/lib/libc/time/Theory:1.18
--- src/lib/libc/time/Theory:1.17	Tue Mar 24 16:01:18 2015
+++ src/lib/libc/time/Theory	Thu Aug 13 07:21:18 2015
@@ -1,233 +1,244 @@
-This file is in the public domain, so clarified as of
-2009-05-17 by Arthur David Olson.
+Theory and pragmatics of the tz code and data
+
 
 ----- Outline -----
 
-	Time and date functions
 	Scope of the tz database
-	Names of time zone rule files
+	Names of time zone rules
 	Time zone abbreviations
+	Accuracy of the tz database
+	Time and date functions
 	Calendrical issues
 	Time and time zones on Mars
 
------ Time and date functions -----
 
-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:
-
-  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.
+----- Scope of the tz database -----
 
-*	In POSIX, time display in a process is controlled by the
-	environment variable TZ.  Unfortunately, the POSIX TZ string takes
-	a form that is hard to describe and is error-prone in practice.
-	Also, POSIX TZ strings can't deal with other (for example, Israeli)
-	daylight saving time rules, or situations where more than two
-	time zone abbreviations are used in an area.
+The tz database attempts to record the history and predicted future of
+all computer-based clocks that track civil time.  To represent this
+data, the world is partitioned into regions whose clocks all agree
+about time stamps that occur after the somewhat-arbitrary cutoff point
+of the POSIX Epoch (1970-01-01 00:00:00 UTC).  For each such region,
+the database records all known clock transitions, and labels the region
+with a notable location.  Although 1970 is a somewhat-arbitrary
+cutoff, there are significant challenges to moving the cutoff earlier
+even by a decade or two, due to the wide variety of local practices
+before computer timekeeping became prevalent.
 
-	The POSIX TZ string takes the following form:
+Clock transitions before 1970 are recorded for each such location,
+because most systems support time stamps before 1970 and could
+misbehave if data entries were omitted for pre-1970 transitions.
+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.
 
-		stdoffset[dst[offset][,date[/time],date[/time]]]
+As described below, reference source code for using the tz database is
+also available.  The tz code is upwards compatible with POSIX, an
+international standard for UNIX-like systems.  As of this writing, the
+current edition of POSIX is:
 
-	where:
+  The Open Group Base Specifications Issue 7
+  IEEE Std 1003.1, 2013 Edition
+  <http://pubs.opengroup.org/onlinepubs/9699919799/>
 
-	std and dst
-		are 3 or more characters specifying the standard
-		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
-		"+" and "-" in the names.
-	offset
-		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.
-		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)
-			origin-1 day number not counting February 29
-		n (0<=n<=365)
-			origin-0 day number counting February 29 if present
-		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
-			(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:
 
-		TZ='PST8PDT,M4.1.0/02:00,M10.5.0/02:00'
+----- Names of time zone rules -----
 
-	This POSIX TZ string is hard to remember, and mishandles time stamps
-	before 1987 and after 2006.  With this package you can use this
-	instead:
+Each of the database's time zone rules has a unique name.
+Inexperienced users are not expected to select these names unaided.
+Distributors should provide documentation and/or a simple selection
+interface that explains the names; for one example, see the 'tzselect'
+program in the tz code.  The Unicode Common Locale Data Repository
+<http://cldr.unicode.org/> contains data that may be useful for other
+selection interfaces.
 
-		TZ='America/Los_Angeles'
+The time zone rule naming conventions attempt to strike a balance
+among the following goals:
 
-*	POSIX does not define the exact meaning of TZ values like "EST5EDT".
-	Typically the current US DST rules are used to interpret such values,
-	but this means that the US DST rules are compiled into each program
-	that does time conversion.  This means that when US time conversion
-	rules change (as in the United States in 1987), all programs that
-	do time conversion must be recompiled to ensure proper results.
+ * Uniquely identify every region where clocks have agreed since 1970.
+   This is essential for the intended use: static clocks keeping local
+   civil time.
+
+ * Indicate to experts where that region is.
+
+ * Be robust in the presence of political changes.  For example, names
+   of countries are ordinarily not used, to avoid incompatibilities
+   when countries change their name (e.g. Zaire->Congo) or when
+   locations change countries (e.g. Hong Kong from UK colony to
+   China).
 
-*	In POSIX, there's no tamper-proof way for a process to learn the
-	system's best idea of local wall clock.  (This is important for
-	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
-	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.)
+ * Be portable to a wide variety of implementations.
 
-*	POSIX requires that systems ignore leap seconds.
+ * Use a consistent naming conventions over the entire world.
 
-*	The tz code 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 and 40-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.
+Names normally have the form AREA/LOCATION, where AREA is the name
+of a continent or ocean, and LOCATION is the name of a specific
+location within that region.  North and South America share the same
+area, 'America'.  Typical names are 'Africa/Cairo', 'America/New_York',
+and 'Pacific/Honolulu'.
 
-These are the extensions that have been made to the POSIX functions:
+Here are the general rules used for choosing location names,
+in decreasing order of importance:
 
-*	The "TZ" environment variable is used in generating the name of a file
-	from which time zone information is read (or is interpreted a la
-	POSIX); "TZ" is no longer constrained to be a three-letter time zone
-	name followed by a number of hours and an optional three-letter
-	daylight time zone name.  The daylight saving time rules to be used
-	for a particular time zone are encoded in the time zone file;
-	the format of the file allows U.S., Australian, and other rules to be
-	encoded, and allows for situations where more than two time zone
-	abbreviations are used.
+	Use only valid POSIX file name components (i.e., the parts of
+		names other than '/').  Do not use the file name
+		components '.' and '..'.  Within a file name component,
+		use only ASCII letters, '.', '-' and '_'.  Do not use
+		digits, as that might create an ambiguity with POSIX
+		TZ strings.  A file name component must not exceed 14
+		characters or start with '-'.  E.g., prefer 'Brunei'
+		to 'Bandar_Seri_Begawan'.  Exceptions: see the discussion
+		of legacy names below.
+	A name must not be empty, or contain '//', or start or end with '/'.
+	Do not use names that differ only in case.  Although the reference
+		implementation is case-sensitive, some other implementations
+		are not, and they would mishandle names differing only in case.
+	If one name A is an initial prefix of another name AB (ignoring case),
+		then B must not start with '/', as a regular file cannot have
+		the same name as a directory in POSIX.  For example,
+		'America/New_York' precludes 'America/New_York/Bronx'.
+	Uninhabited regions like the North Pole and Bouvet Island
+		do not need locations, since local time is not defined there.
+	There should typically be at least one name for each ISO 3166-1
+		officially assigned two-letter code for an inhabited country
+		or territory.
+	If all the clocks in a region have agreed since 1970,
+		don't bother to include more than one location
+		even if subregions' clocks disagreed before 1970.
+		Otherwise these tables would become annoyingly large.
+	If a name is ambiguous, use a less ambiguous alternative;
+		e.g. many cities are named San José and Georgetown, so
+		prefer 'Costa_Rica' to 'San_Jose' and 'Guyana' to 'Georgetown'.
+	Keep locations compact.  Use cities or small islands, not countries
+		or regions, so that any future time zone changes do not split
+		locations into different time zones.  E.g. prefer 'Paris'
+		to 'France', since France has had multiple time zones.
+	Use mainstream English spelling, e.g. prefer 'Rome' to 'Roma', and
+		prefer 'Athens' to the Greek 'Αθήνα' or the Romanized 'Athína'.
+		The POSIX file name restrictions encourage this rule.
+	Use the most populous among locations in a zone,
+		e.g. prefer 'Shanghai' to 'Beijing'.  Among locations with
+		similar populations, pick the best-known location,
+		e.g. prefer 'Rome' to 'Milan'.
+	Use the singular form, e.g. prefer 'Canary' to 'Canaries'.
+	Omit common suffixes like '_Islands' and '_City', unless that
+		would lead to ambiguity.  E.g. prefer 'Cayman' to
+		'Cayman_Islands' and 'Guatemala' to 'Guatemala_City',
+		but prefer 'Mexico_City' to 'Mexico' because the country
+		of Mexico has several time zones.
+	Use '_' to represent a space.
+	Omit '.' from abbreviations in names, e.g. prefer 'St_Helena'
+		to 'St._Helena'.
+	Do not change established names if they only marginally
+		violate the above rules.  For example, don't change
+		the existing name 'Rome' to 'Milan' merely because
+		Milan's population has grown to be somewhat greater
+		than Rome's.
+	If a name is changed, put its old spelling in the 'backward' file.
+		This means old spellings will continue to work.
 
-	It was recognized that allowing the "TZ" environment variable to
-	take on values such as "America/New_York" might cause "old" programs
-	(that expect "TZ" to have a certain form) to operate incorrectly;
-	consideration was given to using some other environment variable
-	(for example, "TIMEZONE") to hold the string used to generate the
-	time zone information file name.  In the end, however, it was decided
-	to continue using "TZ": it is widely used for time zone purposes;
-	separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance;
-	and systems where "new" forms of "TZ" might cause problems can simply
-	use TZ values such as "EST5EDT" which can be used both by
-	"new" programs (a la POSIX) and "old" programs (as zone names and
-	offsets).
+The file 'zone1970.tab' lists geographical locations used 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
+longitude, this relationship is not exact.
 
-*	To handle places where more than two time zone abbreviations are used,
-	the functions "localtime" and "gmtime" set tzname[tmp->tm_isdst]
-	(where "tmp" is the value the function returns) to the time zone
-	abbreviation to be used.  This differs from POSIX, where the elements
-	of tzname are only changed as a result of calls to tzset.
+Older versions of this package used a different naming scheme,
+and these older names are still supported.
+See the file 'backward' for most of these older names
+(e.g., 'US/Eastern' instead of 'America/New_York').
+The other old-fashioned names still supported are
+'WET', 'CET', 'MET', and 'EET' (see the file 'europe').
 
-*	Since the "TZ" environment variable can now be used to control time
-	conversion, the "daylight" and "timezone" variables are no longer
-	needed.  (These variables are defined and set by "tzset"; however, their
-	values will not be used by "localtime.")
+Older versions of this package defined legacy names that are
+incompatible with the first rule of location names, but which are
+still supported.  These legacy names are mostly defined in the file
+'etcetera'.  Also, the file 'backward' defines the legacy names
+'GMT0', 'GMT-0', 'GMT+0' and 'Canada/East-Saskatchewan', and the file
+'northamerica' defines the legacy names 'EST5EDT', 'CST6CDT',
+'MST7MDT', and 'PST8PDT'.
 
-*	The "localtime" function has been set up to deliver correct results
-	for near-minimum or near-maximum time_t values.  (A comment in the
-	source code tells how to get compatibly wrong results).
+Excluding 'backward' should not affect the other data.  If
+'backward' is excluded, excluding 'etcetera' should not affect the
+remaining data.
 
-*	A function "tzsetwall" has been added to arrange for the system's
-	best approximation to local wall clock time to be delivered by
-	subsequent calls to "localtime."  Source code for portable
-	applications that "must" run on local wall clock time should call
-	"tzsetwall();" if such code is moved to "old" systems that don't
-	provide tzsetwall, you won't be able to generate an executable program.
-	(These time zone functions also arrange for local wall clock time to be
-	used if tzset is called - directly or indirectly - and there's no "TZ"
-	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.
+----- Time zone abbreviations -----
 
-*	These functions can account for leap seconds, thanks to Bradley White.
+When this package is installed, it generates time zone abbreviations
+like 'EST' to be compatible with human tradition and POSIX.
+Here are the general rules used for choosing time zone abbreviations,
+in decreasing order of importance:
 
-Points of interest to folks with other systems:
+	Use abbreviations that consist of three or more ASCII letters.
+		Previous editions of this database also used characters like
+		' ' and '?', but these characters have a special meaning to
+		the shell and cause commands like
+			set `date`
+		to have unexpected effects.
+		Previous editions of this rule required upper-case letters,
+		but the Congressman who introduced Chamorro Standard Time
+		preferred "ChST", so the rule has been relaxed.
 
-*	This package is already part of many POSIX-compliant hosts,
-	including BSD, HP, Linux, Network Appliance, SCO, SGI, and Sun.
-	On such hosts, the primary use of this package
-	is to update obsolete time zone rule tables.
-	To do this, you may need to compile the time zone compiler
-	'zic' supplied with this package instead of using the system 'zic',
-	since the format of zic's input changed slightly in late 1994,
-	and many vendors still do not support the new input format.
+		This rule guarantees that all abbreviations could have
+		been specified by a POSIX TZ string.  POSIX
+		requires at least three characters for an
+		abbreviation.  POSIX through 2000 says that an abbreviation
+		cannot start with ':', and cannot contain ',', '-',
+		'+', NUL, or a digit.  POSIX from 2001 on changes this
+		rule to say that an abbreviation can contain only '-', '+',
+		and alphanumeric characters from the portable character set
+		in the current locale.  To be portable to both sets of
+		rules, an abbreviation must therefore use only ASCII
+		letters.
 
-*	The UNIX Version 7 "timezone" function is not present in this package;
-	it's impossible to reliably map timezone's arguments (a "minutes west
-	of GMT" value and a "daylight saving time in effect" flag) to a
-	time zone abbreviation, and we refuse to guess.
-	Programs that in the past used the timezone function may now examine
-	tzname[localtime(&clock)->tm_isdst] to learn the correct time
-	zone abbreviation to use.  Alternatively, use
-	localtime(&clock)->tm_zone if this has been enabled.
+	Use abbreviations that are in common use among English-speakers,
+		e.g. 'EST' for Eastern Standard Time in North America.
+		We assume that applications translate them to other languages
+		as part of the normal localization process; for example,
+		a French application might translate 'EST' to 'HNE'.
 
-*	The 4.2BSD gettimeofday function is not used in this package.
-	This formerly let users obtain the current UTC offset and DST flag,
-	but this functionality was removed in later versions of BSD.
+	For zones whose times are taken from a city's longitude, use the
+		traditional xMT notation, e.g. 'PMT' for Paris Mean Time.
+		The only name like this in current use is 'GMT'.
 
-*	In SVR2, time conversion fails for near-minimum or near-maximum
-	time_t values when doing conversions for places that don't use UT.
-	This package takes care to do these conversions correctly.
+	Use 'LMT' for local mean time of locations before the introduction
+		of standard time; see "Scope of the tz database".
 
-The functions that are conditionally compiled if STD_INSPIRED is defined
-should, at this point, be looked on primarily as food for thought.  They are
-not in any sense "standard compatible" - some are not, in fact, specified in
-*any* standard.  They do, however, represent responses of various authors to
-standardization proposals.
+	If there is no common English abbreviation, use numeric offsets like
+		-05 and +0830 that are generated by zic's %z notation.
 
-Other time conversion proposals, in particular the one developed by folks at
-Hewlett Packard, offer a wider selection of functions that provide capabilities
-beyond those provided here.  The absence of such functions from this package
-is not meant to discourage the development, standardization, or use of such
-functions.  Rather, their absence reflects the decision to make this package
-contain valid extensions to POSIX, to ensure its broad acceptability.  If
-more powerful time conversion functions can be standardized, so much the
-better.
+    [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.]
 
+	If there is no common English abbreviation, abbreviate the English
+		translation of the usual phrase used by native speakers.
+		If this is not available or is a phrase mentioning the country
+		(e.g. "Cape Verde Time"), then:
 
------ Scope of the tz database -----
+		When a country is identified with a single or principal zone,
+			append 'T' to the country's ISO	code, e.g. 'CVT' for
+			Cape Verde Time.  For summer time append 'ST';
+			for double summer time append 'DST'; etc.
+		Otherwise, take the first three letters of an English place
+			name identifying each zone and append 'T', 'ST', etc.
+			as before; e.g. 'VLAST' for VLAdivostok Summer Time.
 
-The tz database attempts to record the history and predicted future of
-all computer-based clocks that track civil time.  To represent this
-data, the world is partitioned into regions whose clocks all agree
-about time stamps that occur after the somewhat-arbitrary cutoff point
-of the POSIX Epoch (1970-01-01 00:00:00 UTC).  For each such region,
-the database records all known clock transitions, and labels the region
-with a notable location.  Although 1970 is a somewhat-arbitrary
-cutoff, there are significant challenges to moving the cutoff earlier
-even by a decade or two, due to the wide variety of local practices
-before computer timekeeping became prevalent.
+	Use UT (with time zone abbreviation 'zzz') for locations while
+		uninhabited.  The 'zzz' mnemonic is that these locations are,
+		in some sense, asleep.
 
-Clock transitions before 1970 are recorded for each such location,
-because most POSIX-compatible systems support negative time stamps and
-could misbehave if data entries were omitted for pre-1970 transitions.
-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.
+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.
 
 
 ----- Accuracy of the tz database -----
@@ -358,194 +369,197 @@ creation of zones merely because two loc
 transitioned to standard time at different dates.
 
 
------ Names of time zone rule files -----
+----- Time and date functions -----
 
-The time zone rule file naming conventions attempt to strike a balance
-among the following goals:
+The tz code contains time and date functions that are upwards
+compatible with those of POSIX.
+
+POSIX has the following properties and limitations.
+
+*	In POSIX, time display in a process is controlled by the
+	environment variable TZ.  Unfortunately, the POSIX TZ string takes
+	a form that is hard to describe and is error-prone in practice.
+	Also, POSIX TZ strings can't deal with other (for example, Israeli)
+	daylight saving time rules, or situations where more than two
+	time zone abbreviations are used in an area.
+
+	The POSIX TZ string takes the following form:
+
+		stdoffset[dst[offset][,date[/time],date[/time]]]
+
+	where:
+
+	std and dst
+		are 3 or more characters specifying the standard
+		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
+		"+" and "-" in the names.
+	offset
+		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.
+		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)
+			origin-1 day number not counting February 29
+		n (0<=n<=365)
+			origin-0 day number counting February 29 if present
+		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
+			(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:
 
- * Uniquely identify every national region where clocks have all
-   agreed since 1970.  This is essential for the intended use: static
-   clocks keeping local civil time.
-
- * Indicate to humans as to where that region is.  This simplifies use.
-
- * Be robust in the presence of political changes.  This reduces the
-   number of updates and backward-compatibility hacks.  For example,
-   names of countries are ordinarily not used, to avoid
-   incompatibilities when countries change their name
-   (e.g. Zaire->Congo) or when locations change countries
-   (e.g. Hong Kong from UK colony to China).
+		TZ='PST8PDT,M4.1.0/02:00,M10.5.0/02:00'
 
- * Be portable to a wide variety of implementations.
-   This promotes use of the technology.
+	This POSIX TZ string is hard to remember, and mishandles time stamps
+	before 1987 and after 2006.  With this package you can use this
+	instead:
 
- * Use a consistent naming convention over the entire world.
-   This simplifies both use and maintenance.
+		TZ='America/Los_Angeles'
 
-This naming convention is not intended for use by inexperienced users
-to select TZ values by themselves (though they can of course examine
-and reuse existing settings).  Distributors should provide
-documentation and/or a simple selection interface that explains the
-names; see the 'tzselect' program supplied with this distribution for
-one example.
+*	POSIX does not define the exact meaning of TZ values like "EST5EDT".
+	Typically the current US DST rules are used to interpret such values,
+	but this means that the US DST rules are compiled into each program
+	that does time conversion.  This means that when US time conversion
+	rules change (as in the United States in 1987), all programs that
+	do time conversion must be recompiled to ensure proper results.
 
-Names normally have the form AREA/LOCATION, where AREA is the name
-of a continent or ocean, and LOCATION is the name of a specific
-location within that region.  North and South America share the same
-area, 'America'.  Typical names are 'Africa/Cairo', 'America/New_York',
-and 'Pacific/Honolulu'.
+*	In POSIX, there's no tamper-proof way for a process to learn the
+	system's best idea of local wall clock.  (This is important for
+	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
+	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.)
 
-Here are the general rules used for choosing location names,
-in decreasing order of importance:
+*	POSIX requires that systems ignore leap seconds.
 
-	Use only valid POSIX file name components (i.e., the parts of
-		names other than '/').  Do not use the file name
-		components '.' and '..'.  Within a file name component,
-		use only ASCII letters, '.', '-' and '_'.  Do not use
-		digits, as that might create an ambiguity with POSIX
-		TZ strings.  A file name component must not exceed 14
-		characters or start with '-'.  E.g., prefer 'Brunei'
-		to 'Bandar_Seri_Begawan'.  Exceptions: see the discussion
-		of legacy names below.
-	A name must not be empty, or contain '//', or start or end with '/'.
-	Do not use names that differ only in case.  Although the reference
-		implementation is case-sensitive, some other implementations
-		are not, and they would mishandle names differing only in case.
-	If one name A is an initial prefix of another name AB (ignoring case),
-		then B must not start with '/', as a regular file cannot have
-		the same name as a directory in POSIX.  For example,
-		'America/New_York' precludes 'America/New_York/Bronx'.
-	Uninhabited regions like the North Pole and Bouvet Island
-		do not need locations, since local time is not defined there.
-	There should typically be at least one name for each ISO 3166-1
-		officially assigned two-letter code for an inhabited country
-		or territory.
-	If all the clocks in a region have agreed since 1970,
-		don't bother to include more than one location
-		even if subregions' clocks disagreed before 1970.
-		Otherwise these tables would become annoyingly large.
-	If a name is ambiguous, use a less ambiguous alternative;
-		e.g. many cities are named San José and Georgetown, so
-		prefer 'Costa_Rica' to 'San_Jose' and 'Guyana' to 'Georgetown'.
-	Keep locations compact.  Use cities or small islands, not countries
-		or regions, so that any future time zone changes do not split
-		locations into different time zones.  E.g. prefer 'Paris'
-		to 'France', since France has had multiple time zones.
-	Use mainstream English spelling, e.g. prefer 'Rome' to 'Roma', and
-		prefer 'Athens' to the Greek 'Αθήνα' or the Romanized 'Athína'.
-		The POSIX file name restrictions encourage this rule.
-	Use the most populous among locations in a zone,
-		e.g. prefer 'Shanghai' to 'Beijing'.  Among locations with
-		similar populations, pick the best-known location,
-		e.g. prefer 'Rome' to 'Milan'.
-	Use the singular form, e.g. prefer 'Canary' to 'Canaries'.
-	Omit common suffixes like '_Islands' and '_City', unless that
-		would lead to ambiguity.  E.g. prefer 'Cayman' to
-		'Cayman_Islands' and 'Guatemala' to 'Guatemala_City',
-		but prefer 'Mexico_City' to 'Mexico' because the country
-		of Mexico has several time zones.
-	Use '_' to represent a space.
-	Omit '.' from abbreviations in names, e.g. prefer 'St_Helena'
-		to 'St._Helena'.
-	Do not change established names if they only marginally
-		violate the above rules.  For example, don't change
-		the existing name 'Rome' to 'Milan' merely because
-		Milan's population has grown to be somewhat greater
-		than Rome's.
-	If a name is changed, put its old spelling in the 'backward' file.
-		This means old spellings will continue to work.
+*	The tz code 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 and 40-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.
 
-The file 'zone1970.tab' lists geographical locations used to name time
-zone rule files.  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
-longitude, this relationship is not exact.
+These are the extensions that have been made to the POSIX functions:
 
-Older versions of this package used a different naming scheme,
-and these older names are still supported.
-See the file 'backward' for most of these older names
-(e.g., 'US/Eastern' instead of 'America/New_York').
-The other old-fashioned names still supported are
-'WET', 'CET', 'MET', and 'EET' (see the file 'europe').
+*	The "TZ" environment variable is used in generating the name of a file
+	from which time zone information is read (or is interpreted a la
+	POSIX); "TZ" is no longer constrained to be a three-letter time zone
+	name followed by a number of hours and an optional three-letter
+	daylight time zone name.  The daylight saving time rules to be used
+	for a particular time zone are encoded in the time zone file;
+	the format of the file allows U.S., Australian, and other rules to be
+	encoded, and allows for situations where more than two time zone
+	abbreviations are used.
 
-Older versions of this package defined legacy names that are
-incompatible with the first rule of location names, but which are
-still supported.  These legacy names are mostly defined in the file
-'etcetera'.  Also, the file 'backward' defines the legacy names
-'GMT0', 'GMT-0', 'GMT+0' and 'Canada/East-Saskatchewan', and the file
-'northamerica' defines the legacy names 'EST5EDT', 'CST6CDT',
-'MST7MDT', and 'PST8PDT'.
+	It was recognized that allowing the "TZ" environment variable to
+	take on values such as "America/New_York" might cause "old" programs
+	(that expect "TZ" to have a certain form) to operate incorrectly;
+	consideration was given to using some other environment variable
+	(for example, "TIMEZONE") to hold the string used to generate the
+	time zone information file name.  In the end, however, it was decided
+	to continue using "TZ": it is widely used for time zone purposes;
+	separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance;
+	and systems where "new" forms of "TZ" might cause problems can simply
+	use TZ values such as "EST5EDT" which can be used both by
+	"new" programs (a la POSIX) and "old" programs (as zone names and
+	offsets).
 
-Excluding 'backward' should not affect the other data.  If
-'backward' is excluded, excluding 'etcetera' should not affect the
-remaining data.
+*	To handle places where more than two time zone abbreviations are used,
+	the functions "localtime" and "gmtime" set tzname[tmp->tm_isdst]
+	(where "tmp" is the value the function returns) to the time zone
+	abbreviation to be used.  This differs from POSIX, where the elements
+	of tzname are only changed as a result of calls to tzset.
 
+*	Since the "TZ" environment variable can now be used to control time
+	conversion, the "daylight" and "timezone" variables are no longer
+	needed.  (These variables are defined and set by "tzset"; however, their
+	values will not be used by "localtime.")
 
------ Time zone abbreviations -----
+*	The "localtime" function has been set up to deliver correct results
+	for near-minimum or near-maximum time_t values.  (A comment in the
+	source code tells how to get compatibly wrong results).
 
-When this package is installed, it generates time zone abbreviations
-like 'EST' to be compatible with human tradition and POSIX.
-Here are the general rules used for choosing time zone abbreviations,
-in decreasing order of importance:
+*	A function "tzsetwall" has been added to arrange for the system's
+	best approximation to local wall clock time to be delivered by
+	subsequent calls to "localtime."  Source code for portable
+	applications that "must" run on local wall clock time should call
+	"tzsetwall();" if such code is moved to "old" systems that don't
+	provide tzsetwall, you won't be able to generate an executable program.
+	(These time zone functions also arrange for local wall clock time to be
+	used if tzset is called - directly or indirectly - and there's no "TZ"
+	environment variable; portable applications should not, however, rely
+	on this behavior since it's not the way SVR2 systems behave.)
 
-	Use abbreviations that consist of three or more ASCII letters.
-		Previous editions of this database also used characters like
-		' ' and '?', but these characters have a special meaning to
-		the shell and cause commands like
-			set `date`
-		to have unexpected effects.
-		Previous editions of this rule required upper-case letters,
-		but the Congressman who introduced Chamorro Standard Time
-		preferred "ChST", so the rule has been relaxed.
+*	Negative time_t values are supported, on systems where time_t is signed.
 
-		This rule guarantees that all abbreviations could have
-		been specified by a POSIX TZ string.  POSIX
-		requires at least three characters for an
-		abbreviation.  POSIX through 2000 says that an abbreviation
-		cannot start with ':', and cannot contain ',', '-',
-		'+', NUL, or a digit.  POSIX from 2001 on changes this
-		rule to say that an abbreviation can contain only '-', '+',
-		and alphanumeric characters from the portable character set
-		in the current locale.  To be portable to both sets of
-		rules, an abbreviation must therefore use only ASCII
-		letters.
+*	These functions can account for leap seconds, thanks to Bradley White.
 
-	Use abbreviations that are in common use among English-speakers,
-		e.g. 'EST' for Eastern Standard Time in North America.
-		We assume that applications translate them to other languages
-		as part of the normal localization process; for example,
-		a French application might translate 'EST' to 'HNE'.
+Points of interest to folks with other systems:
 
-	For zones whose times are taken from a city's longitude, use the
-		traditional xMT notation, e.g. 'PMT' for Paris Mean Time.
-		The only name like this in current use is 'GMT'.
+*	This package is already part of many POSIX-compliant hosts,
+	including BSD, HP, Linux, Network Appliance, SCO, SGI, and Sun.
+	On such hosts, the primary use of this package
+	is to update obsolete time zone rule tables.
+	To do this, you may need to compile the time zone compiler
+	'zic' supplied with this package instead of using the system 'zic',
+	since the format of zic's input changed slightly in late 1994,
+	and many vendors still do not support the new input format.
 
-	If there is no common English abbreviation, abbreviate the English
-		translation of the usual phrase used by native speakers.
-		If this is not available or is a phrase mentioning the country
-		(e.g. "Cape Verde Time"), then:
+*	The UNIX Version 7 "timezone" function is not present in this package;
+	it's impossible to reliably map timezone's arguments (a "minutes west
+	of GMT" value and a "daylight saving time in effect" flag) to a
+	time zone abbreviation, and we refuse to guess.
+	Programs that in the past used the timezone function may now examine
+	tzname[localtime(&clock)->tm_isdst] to learn the correct time
+	zone abbreviation to use.  Alternatively, use
+	localtime(&clock)->tm_zone if this has been enabled.
 
-		When a country is identified with a single or principal zone,
-			append 'T' to the country's ISO	code, e.g. 'CVT' for
-			Cape Verde Time.  For summer time append 'ST';
-			for double summer time append 'DST'; etc.
-		Otherwise, take the first three letters of an English place
-			name identifying each zone and append 'T', 'ST', etc.
-			as before; e.g. 'VLAST' for VLAdivostok Summer Time.
+*	The 4.2BSD gettimeofday function is not used in this package.
+	This formerly let users obtain the current UTC offset and DST flag,
+	but this functionality was removed in later versions of BSD.
 
-	Use 'LMT' for local mean time of locations before the introduction
-		of standard time; see "Scope of the tz database".
+*	In SVR2, time conversion fails for near-minimum or near-maximum
+	time_t values when doing conversions for places that don't use UT.
+	This package takes care to do these conversions correctly.
 
-	Use UT (with time zone abbreviation 'zzz') for locations while
-		uninhabited.  The 'zzz' mnemonic is that these locations are,
-		in some sense, asleep.
+The functions that are conditionally compiled if STD_INSPIRED is defined
+should, at this point, be looked on primarily as food for thought.  They are
+not in any sense "standard compatible" - some are not, in fact, specified in
+*any* standard.  They do, however, represent responses of various authors to
+standardization proposals.
 
-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.
+Other time conversion proposals, in particular the one developed by folks at
+Hewlett Packard, offer a wider selection of functions that provide capabilities
+beyond those provided here.  The absence of such functions from this package
+is not meant to discourage the development, standardization, or use of such
+functions.  Rather, their absence reflects the decision to make this package
+contain valid extensions to POSIX, to ensure its broad acceptability.  If
+more powerful time conversion functions can be standardized, so much the
+better.
 
 
 ----- Calendrical issues -----
@@ -766,6 +780,11 @@ Tom Chmielewski, "Jet Lag Is Worse on Ma
 <http://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/>
 
 -----
+
+This file is in the public domain, so clarified as of 2009-05-17 by
+Arthur David Olson.
+
+-----
 Local Variables:
 coding: utf-8
 End:

Index: src/lib/libc/time/difftime.c
diff -u src/lib/libc/time/difftime.c:1.15 src/lib/libc/time/difftime.c:1.16
--- src/lib/libc/time/difftime.c:1.15	Fri Sep 20 15:06:54 2013
+++ src/lib/libc/time/difftime.c	Thu Aug 13 07:21:18 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: difftime.c,v 1.15 2013/09/20 19:06:54 christos Exp $	*/
+/*	$NetBSD: difftime.c,v 1.16 2015/08/13 11:21:18 christos Exp $	*/
 
 /*
 ** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
 #if 0
 static char	elsieid[] = "@(#)difftime.c	8.1";
 #else
-__RCSID("$NetBSD: difftime.c,v 1.15 2013/09/20 19:06:54 christos Exp $");
+__RCSID("$NetBSD: difftime.c,v 1.16 2015/08/13 11:21:18 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -18,45 +18,52 @@ __RCSID("$NetBSD: difftime.c,v 1.15 2013
 
 #include "private.h"	/* for time_t and TYPE_SIGNED */
 
+/* Return -X as a double.  Using this avoids casting to 'double'.  */
+static double
+dminus(double x)
+{
+	return -x;
+}
+
 double ATTRIBUTE_CONST
-difftime(const time_t time1, const time_t time0)
+difftime(time_t time1, time_t time0)
 {
 	/*
-	** If (sizeof (double) > sizeof (time_t)) simply convert and subtract
+	** If double is large enough, simply convert and subtract
 	** (assuming that the larger type has more precision).
 	*/
-	/*CONSTCOND*/
-	if (sizeof (double) > sizeof (time_t))
-		return (double) time1 - (double) time0;
-	/*LINTED const not */
-	if (!TYPE_SIGNED(time_t)) {
-		/*
-		** The difference of two unsigned values can't overflow
-		** if the minuend is greater than or equal to the subtrahend.
-		*/
-		if (time1 >= time0)
-			return            time1 - time0;
-		else	return -(double) (time0 - time1);
+	if (sizeof (time_t) < sizeof (double)) {
+		double t1 = time1, t0 = time0;
+		return t1 - t0;
+ 	}
+
+	/*
+	** The difference of two unsigned values can't overflow
+	** if the minuend is greater than or equal to the subtrahend.
+	*/
+	if (!TYPE_SIGNED(time_t))
+		return time0 <= time1 ? time1 - time0 : dminus(time0 - time1);
+
+	/* Use uintmax_t if wide enough.  */
+	if (sizeof (time_t) <= sizeof (uintmax_t)) {
+		uintmax_t t1 = time1, t0 = time0;
+		return time0 <= time1 ? t1 - t0 : dminus(t0 - t1);
 	}
+
 	/*
 	** Handle cases where both time1 and time0 have the same sign
 	** (meaning that their difference cannot overflow).
 	*/
 	if ((time1 < 0) == (time0 < 0))
 		return time1 - time0;
+
 	/*
-	** time1 and time0 have opposite signs.
-	** Punt if uintmax_t is too narrow.
+	** The values have opposite signs and uintmax_t is too narrow.
 	** This suffers from double rounding; attempt to lessen that
 	** by using long double temporaries.
 	*/
-	/* CONSTCOND */
-	if (sizeof (uintmax_t) < sizeof (time_t))
-		return (double) time1 - (double) time0;
-	/*
-	** Stay calm...decent optimizers will eliminate the complexity below.
-	*/
-	if (time1 >= 0 /* && time0 < 0 */)
-		return    (uintmax_t) time1 + (uintmax_t) (-(time0 + 1)) + 1;
-	return -(double) ((uintmax_t) time0 + (uintmax_t) (-(time1 + 1)) + 1);
+	{
+		long double t1 = time1, t0 = time0;
+		return t1 - t0;
+	}
 }

Index: src/lib/libc/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.95 src/lib/libc/time/localtime.c:1.96
--- src/lib/libc/time/localtime.c:1.95	Sun Jun 21 12:06:51 2015
+++ src/lib/libc/time/localtime.c	Thu Aug 13 07:21:18 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: localtime.c,v 1.95 2015/06/21 16:06:51 christos Exp $	*/
+/*	$NetBSD: localtime.c,v 1.96 2015/08/13 11:21:18 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.95 2015/06/21 16:06:51 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.96 2015/08/13 11:21:18 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -143,18 +143,20 @@ struct state {
 	int		defaulttype; /* for early times or if no transitions */
 };
 
+enum r_type {
+  JULIAN_DAY,		/* Jn = Julian day */
+  DAY_OF_YEAR,		/* n = day of year */
+  MONTH_NTH_DAY_OF_WEEK	/* Mm.n.d = month, week, day of week */
+};
+
 struct rule {
-	int		r_type;		/* type of rule; see below */
+	enum r_type	r_type;		/* type of rule */
 	int		r_day;		/* day number of rule */
 	int		r_week;		/* week number of rule */
 	int		r_mon;		/* month number of rule */
 	int_fast32_t	r_time;		/* transition time of rule */
 };
 
-#define JULIAN_DAY		0	/* Jn = Julian day */
-#define DAY_OF_YEAR		1	/* n = day of year */
-#define MONTH_NTH_DAY_OF_WEEK	2	/* Mm.n.d = month, week, day of week */
-
 static struct tm *gmtsub(struct state const *, time_t const *, int_fast32_t,
 			 struct tm *);
 static bool increment_overflow(int *, int);
@@ -695,7 +697,7 @@ tzload(char const *name, struct state *s
 }
 
 static bool
-typesequiv(struct state const *sp, int a, int b)
+typesequiv(const struct state *sp, int a, int b)
 {
 	bool result;
 
@@ -1011,13 +1013,13 @@ transtime(const int year, const struct r
 */
 
 static bool
-tzparse(const char *name, timezone_t sp,
-	bool lastditch)
+tzparse(const char *name, struct state *sp, bool lastditch)
 {
 	const char *	stdname;
 	const char *	dstname;
 	size_t		stdlen;
 	size_t		dstlen;
+	size_t		charcnt;
 	int_fast32_t	stdoffset;
 	int_fast32_t	dstoffset;
 	char *		cp;
@@ -1026,10 +1028,8 @@ tzparse(const char *name, timezone_t sp,
 	dstname = NULL; /* XXX gcc */
 	stdname = name;
 	if (lastditch) {
-		stdlen = strlen(name);	/* length of standard zone name */
+		stdlen = sizeof gmt - 1;
 		name += stdlen;
-		if (stdlen >= sizeof sp->chars)
-			stdlen = (sizeof sp->chars) - 1;
 		stdoffset = 0;
 	} else {
 		if (*name == '<') {
@@ -1044,12 +1044,15 @@ tzparse(const char *name, timezone_t sp,
 			name = getzname(name);
 			stdlen = name - stdname;
 		}
-		if (*name == '\0')
+		if (!stdlen)
 			return false;
 		name = getoffset(name, &stdoffset);
 		if (name == NULL)
 			return false;
 	}
+	charcnt = stdlen + 1;
+	if (sizeof sp->chars < charcnt)
+		return false;
 	load_ok = tzload(TZDEFRULES, sp, false) == 0;
 	if (!load_ok)
 		sp->leapcnt = 0;		/* so, we're off a little */
@@ -1066,6 +1069,11 @@ tzparse(const char *name, timezone_t sp,
 			name = getzname(name);
 			dstlen = name - dstname; /* length of DST zone name */
 		}
+		if (!dstlen)
+		  return false;
+		charcnt += dstlen + 1;
+		if (sizeof sp->chars < charcnt)
+		  return false;
 		if (*name != '\0' && *name != ',' && *name != ';') {
 			name = getoffset(name, &dstoffset);
 			if (name == NULL)
@@ -1229,11 +1237,7 @@ tzparse(const char *name, timezone_t sp,
 		init_ttinfo(&sp->ttis[1], 0, false, 0);
 		sp->defaulttype = 0;
 	}
-	sp->charcnt = (int)(stdlen + 1);
-	if (dstlen != 0)
-		sp->charcnt += (int)(dstlen + 1);
-	if ((size_t) sp->charcnt > sizeof sp->chars)
-		return false;
+	sp->charcnt = charcnt;
 	cp = sp->chars;
 	(void) memcpy(cp, stdname, stdlen);
 	cp += stdlen;
@@ -1493,7 +1497,7 @@ localtime_tzset(time_t const *timep, str
 }
 
 struct tm *
-localtime(const time_t *const timep)
+localtime(const time_t *timep)
 {
 	return localtime_tzset(timep, &tm, true);
 }
@@ -1528,27 +1532,27 @@ gmtsub(struct state const *sp, const tim
 	return result;
 }
 
-struct tm *
-gmtime(const time_t *const timep)
-{
-	return gmtime_r(timep, &tm);
-}
 
 /*
 ** Re-entrant version of gmtime.
 */
 
 struct tm *
-gmtime_r(const time_t * const timep, struct tm *tmp)
+gmtime_r(const time_t *timep, struct tm *tmp)
 {
 	gmtcheck();
 	return gmtsub(NULL, timep, 0, tmp);
 }
 
+struct tm *
+gmtime(const time_t *timep)
+{
+	return gmtime_r(timep, &tm);
+}
 #ifdef STD_INSPIRED
 
 struct tm *
-offtime(const time_t *const timep, long offset)
+offtime(const time_t *timep, long offset)
 {
 	gmtcheck();
 	return gmtsub(gmtptr, timep, (int_fast32_t)offset, &tm);
@@ -1576,8 +1580,8 @@ leaps_thru_end_of(const int y)
 }
 
 static struct tm *
-timesub(time_t const *timep, int_fast32_t offset, struct state const *sp,
-	struct tm *tmp)
+timesub(const time_t *timep, int_fast32_t offset,
+    const struct state const *sp, struct tm *tmp)
 {
 	const struct lsinfo *	lp;
 	time_t			tdays;
@@ -1614,7 +1618,7 @@ timesub(time_t const *timep, int_fast32_
 	}
 	y = EPOCH_YEAR;
 	tdays = (time_t)(*timep / SECSPERDAY);
-	rem = (int_fast64_t) (*timep - tdays * SECSPERDAY);
+	rem = *timep % SECSPERDAY;
 	while (tdays < 0 || tdays >= year_lengths[isleap(y)]) {
 		int		newy;
 		time_t	tdelta;
@@ -1638,13 +1642,6 @@ timesub(time_t const *timep, int_fast32_
 		tdays -= leapdays;
 		y = newy;
 	}
-	{
-		int_fast32_t seconds;
-
-		seconds = (int_fast32_t)(tdays * SECSPERDAY);
-		tdays = (time_t)(seconds / SECSPERDAY);
-		rem += (int_fast64_t)(seconds - tdays * SECSPERDAY);
-	}
 	/*
 	** Given the range, we can now fearlessly cast...
 	*/
@@ -1707,7 +1704,7 @@ out_of_range:
 }
 
 char *
-ctime(const time_t *const timep)
+ctime(const time_t *timep)
 {
 /*
 ** Section 4.12.3.2 of X3.159-1989 requires that
@@ -1720,7 +1717,7 @@ ctime(const time_t *const timep)
 }
 
 char *
-ctime_r(const time_t *const timep, char *buf)
+ctime_r(const time_t *timep, char *buf)
 {
 	struct tm mytm;
 	struct tm *tmp = localtime_r(timep, &mytm);
@@ -1756,7 +1753,7 @@ ctime_rz(const timezone_t sp, const time
 */
 
 static bool
-increment_overflow(int *const ip, int j)
+increment_overflow(int *ip, int j)
 {
 	int const	i = *ip;
 
@@ -1812,8 +1809,7 @@ normalize_overflow(int *const tensptr, i
 }
 
 static bool
-normalize_overflow32(int_fast32_t *const tensptr, int *const unitsptr,
-		     const int base)
+normalize_overflow32(int_fast32_t *tensptr, int *unitsptr, int base)
 {
 	int	tensdelta;
 
@@ -2194,7 +2190,7 @@ mktime_z(timezone_t sp, struct tm *const
 #endif
 
 time_t
-mktime(struct tm *const tmp)
+mktime(struct tm *tmp)
 {
 	time_t t;
 
@@ -2216,7 +2212,7 @@ timelocal_z(const timezone_t sp, struct 
 }
 
 time_t
-timelocal(struct tm *const tmp)
+timelocal(struct tm *tmp)
 {
 	if (tmp != NULL)
 		tmp->tm_isdst = -1;	/* in case it wasn't initialized */
@@ -2224,14 +2220,14 @@ timelocal(struct tm *const tmp)
 }
 
 time_t
-timegm(struct tm *const tmp)
+timegm(struct tm *tmp)
 {
 
 	return timeoff(tmp, 0);
 }
 
 time_t
-timeoff(struct tm *const tmp, long offset)
+timeoff(struct tm *tmp, long offset)
 {
 	if (tmp)
 		tmp->tm_isdst = 0;

Index: src/lib/libc/time/private.h
diff -u src/lib/libc/time/private.h:1.42 src/lib/libc/time/private.h:1.43
--- src/lib/libc/time/private.h:1.42	Mon Jun 22 13:43:23 2015
+++ src/lib/libc/time/private.h	Thu Aug 13 07:21:18 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: private.h,v 1.42 2015/06/22 17:43:23 christos Exp $	*/
+/*	$NetBSD: private.h,v 1.43 2015/08/13 11:21:18 christos Exp $	*/
 
 #ifndef PRIVATE_H
 #define PRIVATE_H
@@ -31,13 +31,9 @@
 
 /*
 ** Defaults for preprocessor symbols.
-** You can override these in your C compiler options, e.g. '-DHAVE_ADJTIME=0'.
+** You can override these in your C compiler options, e.g. '-DHAVE_GETTEXT=1'.
 */
 
-#ifndef HAVE_ADJTIME
-#define HAVE_ADJTIME		1
-#endif /* !defined HAVE_ADJTIME */
-
 #ifndef HAVE_GETTEXT
 #define HAVE_GETTEXT		0
 #endif /* !defined HAVE_GETTEXT */
@@ -50,10 +46,6 @@
 #define HAVE_LINK		1
 #endif /* !defined HAVE_LINK */
 
-#ifndef HAVE_SETTIMEOFDAY
-#define HAVE_SETTIMEOFDAY	3
-#endif /* !defined HAVE_SETTIMEOFDAY */
-
 #ifndef HAVE_STRDUP
 #define HAVE_STRDUP 1
 #endif
@@ -75,7 +67,7 @@
 #endif /* !defined HAVE_UNISTD_H */
 
 #ifndef HAVE_UTMPX_H
-#define HAVE_UTMPX_H		0
+#define HAVE_UTMPX_H		1
 #endif /* !defined HAVE_UTMPX_H */
 
 #ifndef NETBSD_INSPIRED
@@ -211,7 +203,7 @@ typedef long long	int_fast64_t;
 #  define INT_FAST64_MIN LLONG_MIN
 #  define INT_FAST64_MAX LLONG_MAX
 # else
-#  if (LONG_MAX >> 31) < 0xffffffff
+#  if LONG_MAX >> 31 < 0xffffffff
 Please use a compiler that supports a 64-bit integer type (or wider);
 you may need to compile with "-DHAVE_STDINT_H".
 #  endif
@@ -263,6 +255,18 @@ typedef long intmax_t;
 # endif
 #endif
 
+#ifndef UINT_FAST64_MAX
+# if defined ULLONG_MAX || defined __LONG_LONG_MAX__
+typedef unsigned long long uint_fast64_t;
+# else
+#  if ULONG_MAX >> 31 >> 1 < 0xffffffff
+Please use a compiler that supports a 64-bit integer type (or wider);
+you may need to compile with "-DHAVE_STDINT_H".
+#  endif
+typedef unsigned long	uint_fast64_t;
+# endif
+#endif
+
 #ifndef UINTMAX_MAX
 # if defined ULLONG_MAX || defined __LONG_LONG_MAX__
 typedef unsigned long long uintmax_t;

Index: src/lib/libc/time/strftime.c
diff -u src/lib/libc/time/strftime.c:1.33 src/lib/libc/time/strftime.c:1.34
--- src/lib/libc/time/strftime.c:1.33	Tue Oct  7 17:51:03 2014
+++ src/lib/libc/time/strftime.c	Thu Aug 13 07:21:18 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: strftime.c,v 1.33 2014/10/07 21:51:03 christos Exp $	*/
+/*	$NetBSD: strftime.c,v 1.34 2015/08/13 11:21:18 christos Exp $	*/
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
@@ -6,7 +6,7 @@
 static char	elsieid[] = "@(#)strftime.c	7.64";
 static char	elsieid[] = "@(#)strftime.c	8.3";
 #else
-__RCSID("$NetBSD: strftime.c,v 1.33 2014/10/07 21:51:03 christos Exp $");
+__RCSID("$NetBSD: strftime.c,v 1.34 2015/08/13 11:21:18 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -152,8 +152,8 @@ strftime_lz(const timezone_t sp, char *c
 }
 
 static char *
-_fmt(const timezone_t sp, const char *format, const struct tm *const t,
-	char *pt, const char *const ptlim, int *warnp, locale_t loc)
+_fmt(const timezone_t sp, const char *format, const struct tm *t, char *pt,
+     const char *ptlim, int *warnp, locale_t loc)
 {
 	for ( ; *format; ++format) {
 		if (*format == '%') {
@@ -610,8 +610,7 @@ label:
 }
 
 size_t
-strftime(char * const s, const size_t maxsize,
-    const char * const format, const struct tm * const	t)
+strftime(char *s, size_t maxsize, const char *format, const struct tm *t)
 {
 	tzset();
 	return strftime_z(NULL, s, maxsize, format, t);
@@ -626,8 +625,7 @@ strftime_l(char * __restrict s, size_t m
 }
 
 static char *
-_conv(const int	n, const char *const format, char *const pt,
-    const char *const ptlim)
+_conv(int n, const char *format, char *pt, const char *ptlim)
 {
 	char	buf[INT_STRLEN_MAXIMUM(int) + 1];
 
@@ -636,7 +634,7 @@ _conv(const int	n, const char *const for
 }
 
 static char *
-_add(const char *str, char *pt, const char *const ptlim)
+_add(const char *str, char *pt, const char *ptlim)
 {
 	while (pt < ptlim && (*pt = *str++) != '\0')
 		++pt;
@@ -653,7 +651,7 @@ _add(const char *str, char *pt, const ch
 
 static char *
 _yconv(int a, int b, bool convert_top, bool convert_yy,
-    char *pt, const char *const ptlim)
+    char *pt, const char * ptlim)
 {
 	int	lead;
 	int	trail;

Index: src/lib/libc/time/tz-art.htm
diff -u src/lib/libc/time/tz-art.htm:1.9 src/lib/libc/time/tz-art.htm:1.10
--- src/lib/libc/time/tz-art.htm:1.9	Sat Jan 31 13:55:17 2015
+++ src/lib/libc/time/tz-art.htm	Thu Aug 13 07:21:18 2015
@@ -34,7 +34,7 @@ Todd Strait, drums</td></tr>
 <tr><td>Notes</td><td>CD notes "additional lyric by Karrin Allyson;
 arranged by Russ Long and Karrin Allyson"</td></tr>
 <tr><td>ADO Rating</td><td>1 star</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=A1fdovw9ta92k";>AMG Rating</a></td><td>4 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/i-didnt-know-about-you-mw0000618657";>AMG Rating</a></td><td>4 stars</td></tr>
 <tr><td>Penguin Rating</td><td>3.5 stars</td></tr>
 <tr><td>&nbsp;</td></tr>
 <tr><td>Artist</td><td>Kevin Mahogany</td></tr>
@@ -49,7 +49,7 @@ Ray Drummond, bass;
 Ralph Moore, tenor saxophone;
 Lewis Nash, drums</td></tr>
 <tr><td>ADO Rating</td><td>1.5 stars</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=Akikbikzjbb19";>AMG Rating</a></td><td>3 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/double-rainbow-mw0000620371";>AMG Rating</a></td><td>3 stars</td></tr>
 <tr><td>Penguin Rating</td><td>3 stars</td></tr>
 <tr><td>&nbsp;</td></tr>
 <tr><td>Artist</td><td>Joe Williams</td></tr>
@@ -63,7 +63,7 @@ The Robert Farnon [39 piece] Orchestra</
 <tr><td>Notes</td><td>This CD is also available as part of a 3-CD package from
 Telarc, "Triple Play" (CD-83461)</td></tr>
 <tr><td>ADO Rating</td><td>black dot</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=Amyyvad6kt8w1";>AMG Rating</a></td><td>2 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/heres-to-life-mw0000623648";>AMG Rating</a></td><td>2 stars</td></tr>
 <tr><td>Penguin Rating</td><td>3 stars</td></tr>
 <tr><td>&nbsp;</td></tr>
 <tr><td>Artist</td><td>Charles Fambrough</td></tr>
@@ -77,10 +77,8 @@ Joel Levine, tenor recorder;
 Edward Simon, piano;
 Lenny White, drums;
 Marion Simon, percussion</td></tr>
-<tr><td>Notes</td><td>On-line information and samples available at
-<a href="http://wwmusic.com/~music/audioq/rel/1033.html";>http://wwmusic.com/~music/audioq/rel/1033.html</a></td></tr>
 <tr><td>ADO Rating</td><td>2 stars</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=A5rkcikcjbb89";>AMG Rating</a></td><td>unrated</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/keeper-of-the-spirit-mw0000176559";>AMG Rating</a></td><td>unrated</td></tr>
 <tr><td>Penguin Rating</td><td>3 stars</td></tr>
 </table>
 <hr>
@@ -98,7 +96,7 @@ David Piltch, string bass</td></tr>
 <tr><td>Notes</td><td>Lyrical reference to "Eastern Standard Time" in
 Tom Waits' "Purple Avenue"</td></tr>
 <tr><td>ADO Rating</td><td>2.5 stars</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=A3a9ds37ya3dg";>AMG Rating</a></td><td>3 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/blame-it-on-my-youth-mw0000274303";>AMG Rating</a></td><td>3 stars</td></tr>
 <tr><td>Penguin Rating</td><td>unrated</td></tr>
 <tr><td>&nbsp;</td></tr>
 <tr><td>Artist</td><td>Milt Hinton</td></tr>
@@ -125,11 +123,11 @@ Sometimes I'm Happy,
 A Hot Time in the Old Town Tonight,
 Four or Five Times, Now's the Time,
 Time on My Hands, This Time It's Us,
-and Good Time Charlie
-On-line samples available at
-<a href="http://www.chiaroscurojazz.com/albuminfo.php4?albumid=49";>http://www.chiaroscurojazz.com/albuminfo.php3?albumid=49</a></td></tr>
+and Good Time Charlie.
+<a href="http://www.chiaroscurojazz.com/album.php?C=310";>Album info</a>
+is available.</td></tr>
 <tr><td>ADO Rating</td><td>3 stars</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=A1cbyxdab8ola";>AMG Rating</a></td><td>4.5 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/old-man-time-mw0000269353";>AMG Rating</a></td><td>4.5 stars</td></tr>
 <tr><td>Penguin Rating</td><td>3 stars</td></tr>
 <tr><td>&nbsp;</td></tr>
 <tr><td>Artist</td><td>Alan Broadbent</td></tr>
@@ -143,7 +141,7 @@ Putter Smith, Bass;
 Frank Gibson, Jr., drums</td></tr>
 <tr><td>Notes</td><td>The CD cover features an analemma for equation-of-time fans</td></tr>
 <tr><td>ADO Rating</td><td>1 star</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=Asl8zefuk8gfo";>AMG Rating</a></td><td>4 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/pacific-standard-time-mw0000645433";>AMG Rating</a></td><td>4 stars</td></tr>
 <tr><td>Penguin Rating</td><td>3.5 stars</td></tr>
 <tr><td>&nbsp;</td></tr>
 <tr><td>Artist</td><td>Anthony Braxton/Richard Teitelbaum</td></tr>
@@ -158,7 +156,7 @@ Leo Smith, trumpet and miscellaneous ins
 Leroy Jenkins, violin and miscellaneous instruments;
 Richard Teitelbaum, modular moog and micromoog synthesizer</td></tr>
 <tr><td>ADO Rating</td><td>black dot</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=A5bkvu3xjan1k";>AMG Rating</a></td><td>unrated</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/silence-time-zones-mw0000595735";>AMG Rating</a></td><td>4 stars</td></tr>
 <tr><td>&nbsp;</td></tr>
 <tr><td>Artist</td><td>Charles Gayle</td></tr>
 <tr><td>CD</td><td>Time Zones</td></tr>
@@ -168,7 +166,7 @@ Richard Teitelbaum, modular moog and mic
 <tr><td>Total Time</td><td>49:06</td></tr>
 <tr><td>Personnel</td><td>Charles Gayle, piano</td></tr>
 <tr><td>ADO Rating</td><td>1 star</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=10:13rc28vw054a";>AMG Rating</a></td><td>4.5 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/time-zones-mw0000349642";>AMG Rating</a></td><td>4.5 stars</td></tr>
 <tr><td>&nbsp;</td></tr>
 <tr><td>Artist</td><td>The Get Up Kids</td></tr>
 <tr><td>CD</td><td>Eudora</td></tr>
@@ -177,7 +175,7 @@ Richard Teitelbaum, modular moog and mic
 <tr><td>ID</td><td>357</td></tr>
 <tr><td>Total Time</td><td>65:12</td></tr>
 <tr><td>Notes</td><td>Includes the song "Central Standard Time." Thanks to Colin Bowern for this information.</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&amp;sql=10:7ddovwvla9xk";>AMG Rating</a></td><td>2.5 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/eudora-mw0000592063";>AMG Rating</a></td><td>2.5 stars</td></tr>
 <tr><td>&nbsp;</td></tr>
 
 <tr><td>Artist</td><td>Coldplay</td></tr>
@@ -195,7 +193,7 @@ line is "Lights go out and I can't be sa
 <tr><td>Artist</td><td>Irving Kahal and Harry Richman</td></tr>
 <tr><td>Song</td><td>There Ought to be a Moonlight Saving Time</td></tr>
 <tr><td>Copyright Date</td><td>1931</td>
-<tr><td>Notes</td><td>This musical standard was a #1 hit for Guy Lombardo
+<tr><td>Notes</td><td>This musical standard was a No. 1 hit for Guy Lombardo
 in 1931, and was also performed by Maurice Chevalier, Blossom Dearie
 and many others. The phrase "Moonlight saving time" also appears in
 the 1995 country song "Not Enough Hours in the Night" written by Aaron
@@ -210,7 +208,7 @@ Supernaw.</td></tr>
 <tr><td>ID</td><td>272</td></tr>
 <tr><td>Total Time</td><td>73:05</td></tr>
 <tr><td>Notes</td><td>Includes the song "Twilight Time Zone."</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&sql=10:w9fpxzykldje";>AMG Rating</a></td><td>3.5 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/lobster-leaps-in-mw0000794929";>AMG Rating</a></td><td>3.5 stars</td></tr>
 <tr><td>ADO Rating</td><td>2 stars</td></tr>
 
 <tr><td>&nbsp;</td></tr>
@@ -221,7 +219,7 @@ Supernaw.</td></tr>
 <tr><td>Label</td><td>Columbia</td></tr>
 <tr><td>ID</td><td>CK-8905</td></tr>
 <tr><td>Total Time</td><td>45:36</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&sql=10:gifqxqt5ld0e";>AMG Rating</a></td><td>4.5 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/the-times-they-a-changin-mw0000202344";>AMG Rating</a></td><td>4.5 stars</td></tr>
 <tr><td>ADO Rating</td><td>1.5 stars</td></tr>
 <tr><td>Notes<td>The title song is also available on "Bob Dylan's Greatest Hits" and "The Essential Bob Dylan."</td></tr>
 <tr><td>&nbsp;</td></tr>
@@ -232,7 +230,7 @@ Supernaw.</td></tr>
 <tr><td>Label</td><td>Universal Jazz France</td></tr>
 <tr><td>ID</td><td>B0012688-02</td></tr>
 <tr><td>Total Time</td><td>42:31</td></tr>
-<tr><td><a href="http://www.allmusic.com/cg/amg.dll?p=amg&sql=10:3bftxzw0ldhe";</a>AMG Rating</a></td><td>3.5 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/tide-mw0000815692";>AMG Rating</a></td><td>3.5 stars</td></tr>
 <tr><td>ADO Rating</td><td>2.5 stars</td></tr>
 <tr><td>Notes<td>Includes the song "Fire and Wood" with the lyric
 "The clocks were turned back you remember/Think it's still November."
@@ -245,7 +243,7 @@ Supernaw.</td></tr>
 <tr><td>ID</td><td>B0005171-02</td></tr>
 <tr><td>Total Time</td><td>156:22</td></tr>
 <tr><td>ADO Rating</td><td>1 star</td></tr>
-<tr><td><a href="http://www.allmusic.com/album/youre-getting-better-the-word-jazz-dot-masters+r105931";>AMG Rating</a></td><td>4.5 stars</td></tr>
+<tr><td><a href="http://www.allmusic.com/album/youre-getting-better-the-word-jazz-dot-masters-mw0000736197";>AMG Rating</a></td><td>4.5 stars</td></tr>
 <tr><td>Notes</td><td>Includes the piece "What Time Is It"
 ("He knew what time it was everywhere...that counted").</td></tr>
 <tr><td>&nbsp;</td></tr>
@@ -491,6 +489,13 @@ or are you just trying to dazzle me with
 entitled "The Kid," originally aired 1997-11-04)
 </li>
 <li>
+"I put myself and my staff through this crazy, huge ordeal, all because
+I refused to go on at midnight, okay?  And so I work, you know, and
+then I get this job at eleven, supposed to be a big deal.  Then
+yesterday daylight [saving] time ended. Right now it's basically
+midnight." (Conan O'Brien on the 2010-11-08 premiere of <em>Conan</em>.)
+</li>
+<li>
 Peppermint Patty: "What if the world comes to an end tonight, Marcie?"
 <br>
 Marcie: "I promise there'll be a tomorrow, sir ... in fact,
@@ -498,13 +503,6 @@ it's already tomorrow in Australia!"
 <br>
 (Charles M. Schulz, <em>Peanuts</em>, 1980-06-13)
 </li>
-<li>
-"I put myself and my staff through this crazy, huge ordeal, all because
-I refused to go on at midnight, okay?  And so I work, you know, and
-then I get this job at eleven, supposed to be a big deal.  Then
-yesterday daylight [saving] time ended. Right now it's basically
-midnight." (Conan O'Brien on the 2010-11-08 premiere of <em>Conan</em>.)
-</li>
 </ul>
 </body>
 </html>

Index: src/lib/libc/time/tz-link.htm
diff -u src/lib/libc/time/tz-link.htm:1.22 src/lib/libc/time/tz-link.htm:1.23
--- src/lib/libc/time/tz-link.htm:1.22	Tue Apr 28 13:00:24 2015
+++ src/lib/libc/time/tz-link.htm	Thu Aug 13 07:21:18 2015
@@ -8,7 +8,7 @@
 <meta http-equiv="Content-type" content='text/html; charset="UTF-8"'>
 <meta name="DC.Creator" content="Eggert, Paul">
 <meta name="DC.Contributor" content="Olson, Arthur David">
-<meta name="DC.Date" content="2015-03-25">
+<meta name="DC.Date" content="2015-08-10">
 <meta name="DC.Description"
  content="Sources of information about time zones and daylight saving time">
 <meta name="DC.Identifier"
@@ -20,14 +20,14 @@
 <h1>Sources for Time Zone and Daylight Saving Time Data</h1>
 <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>
+The <a href="https://en.wikipedia.org/wiki/Public_domain";>public-domain</a>
 time zone database 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 <a href="http://en.wikipedia.org/wiki/Time_zone";>time zone</a>
+to <a href="https://en.wikipedia.org/wiki/Time_zone";>time zone</a>
 boundaries and
-<a href="http://en.wikipedia.org/wiki/Daylight_saving_time";>daylight-saving</a>
+<a href="https://en.wikipedia.org/wiki/Daylight_saving_time";>daylight-saving</a>
 rules.
 This database (often called <code>zoneinfo</code> or
 <code><abbr>tz</abbr></code>)
@@ -36,27 +36,27 @@ including
 <a href="http://www.gnu.org/software/libc/";>the
 <abbr title="GNU's Not Unix">GNU</abbr>
 C Library</a> (used in
-<a href="http://en.wikipedia.org/wiki/Linux";><abbr>GNU</abbr>/Linux</a>),
+<a href="https://en.wikipedia.org/wiki/Linux";><abbr>GNU</abbr>/Linux</a>),
 <a href="http://www.android.com";>Android</a>,
 <a href="https://developer.mozilla.org/en-US/Firefox_OS";>Firefox
 <abbr title="Operating System">OS</abbr></a>,
 <a href="https://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://www.openbsd.org";>Open<abbr>BSD</abbr></a>,
 <a href="https://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/MINIX";>MINIX</a>,
-<a href="http://en.wikipedia.org/wiki/WebOS";><abbr
+<a href="https://en.wikipedia.org/wiki/MINIX";>MINIX</a>,
+<a href="https://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="https://en.wikipedia.org/wiki/BlackBerry_10";>BlackBerry 10</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
+<a href="http://www8.hp.com/us/en/products/servers/openvms/overview.html";>Open<abbr
 title="Virtual Memory System">VMS</abbr></a>,
 <a href="https://www.oracle.com/database/index.html";>Oracle Database</a>,
 <a href="http://oracle.com/solaris";>Oracle Solaris</a>, and
@@ -78,19 +78,19 @@ and other entries represent smaller regi
 Indiana, which switched from central to eastern time in 1991
 and switched back in 2006.
 To use the database on an extended <a
-href="http://en.wikipedia.org/wiki/POSIX";><abbr
+href="https://en.wikipedia.org/wiki/POSIX";><abbr
 title="Portable Operating System Interface">POSIX</abbr></a>
 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>
 Associated with each region is a history of offsets from
-<a href="http://en.wikipedia.org/wiki/Universal_Time";>Universal
+<a href="https://en.wikipedia.org/wiki/Universal_Time";>Universal
 Time</a> (<abbr>UT</abbr>), which is <a
-href="http://en.wikipedia.org/wiki/Greenwich_Mean_Time";>Greenwich Mean
+href="https://en.wikipedia.org/wiki/Greenwich_Mean_Time";>Greenwich Mean
 Time</a> (<abbr>GMT</abbr>) with days beginning at midnight;
 for time stamps after 1960 this is more precisely <a
-href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time";>Coordinated
+href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time";>Coordinated
 Universal Time</a> (<abbr>UTC</abbr>).
 The database also records when daylight saving time was in use,
 along with alphabetic time zone abbreviations such as <abbr>EST</abbr>
@@ -113,7 +113,7 @@ code</a> and
 <a href="ftp://ftp.iana.org/tz/tzdata-latest.tar.gz";>latest data</a> revisions
 are also available.
 The following <a
-href="http://en.wikipedia.org/wiki/Unix_shell";>shell</a> commands download
+href="https://en.wikipedia.org/wiki/Unix_shell";>shell</a> commands download
 these files to a <abbr>GNU</abbr>/Linux or similar host;
 see the downloaded
 <code>README</code> file for what to do next.</p>
@@ -158,9 +158,9 @@ Here are some links that may be of inter
 <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
+<a href="https://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
+<li><a href="https://web.archive.org/web/20140221080916/http://www.cstdbill.com/tzdb/tz-how-to.html";>How to Read the
 tz Database Source Files</a> explains the <code><abbr>tz</abbr></code>
 database format.</li>
 <li><a
@@ -186,11 +186,8 @@ Converter</a>
 uses a pulldown menu.</li>
 <li><a href="http://home.kpn.nl/vanadovv/time/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;
+<li><a href="http://www.timeanddate.com/worldclock/";>The World Clock &ndash;
 Time Zones</a> lets you sort zone names and convert times.</li>
-<li><a href="http://permatime.com";>Permatime</a> generates and views
-links that refer to a particular point in time and can be displayed in
-multiple time zones.</li>
 <li><a href="http://www.zeitverschiebung.net/en/";>Time Difference</a>
 calculates the current time difference between locations.</li>
 <li><a href="http://www.wx-now.com";>Weather Now</a> lists the weather too.</li>
@@ -251,7 +248,7 @@ data</a> converted from <code><abbr>tz</
 <h2>Other <code><abbr>tz</abbr></code> compilers</h2>
 <ul>
 <li><a href="http://sourceforge.net/projects/vzic/";>Vzic</a> is a <a
-href="http://en.wikipedia.org/wiki/C_%28programming_language%29";>C</a>
+href="https://en.wikipedia.org/wiki/C_%28programming_language%29";>C</a>
 program that compiles
 <code><abbr>tz</abbr></code> source into iCalendar-compatible VTIMEZONE files.
 Vzic is freely
@@ -259,9 +256,9 @@ 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 &ndash; 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>
+href="https://msdn.microsoft.com/netframework";>.NET framework</a>
 and with a <abbr>BSD</abbr>-style license.</li>
 <li><a
 href="http://search.cpan.org/dist/DateTime-TimeZone/";>DateTime::TimeZone</a>
@@ -273,9 +270,15 @@ available under both the <abbr>GPL</abbr
 License. DateTime::TimeZone also contains a script
 <code>tests_from_zdump</code> that generates test cases for each clock
 transition in the <code><abbr>tz</abbr></code> database.</li>
-<li><a href="http://icu-project.org";>International Components for
+<li>The <a href="http://howardhinnant.github.io/tz.html";>Time Zone
+Database Parser</a> is a
+<a href="https://en.wikipedia.org/wiki/C%2B%2B";>C++</a> parser and
+runtime library. It is freely available under the
+<a href="http://creativecommons.org/licenses/by/4.0/";>Creative Commons
+Attribution 4.0 International Public License</a>.</li>
+<li><a href="http://site.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>
+href="https://en.wikipedia.org/wiki/Java_%28programming_language%29";>Java</a>
 libraries for internationalization that
 has a compiler from <code><abbr>tz</abbr></code> source
 and from <abbr title="Common Locale Data Repository">CLDR</abbr> data
@@ -299,7 +302,7 @@ are similar to Joda Time, but for the .N
 Java. They are freely available under the
 <a href="http://www.apache.org/licenses/LICENSE-2.0";>Apache License</a>
 and a <abbr>BSD</abbr>-style license, respectively.</li>
-<li><a href="http://en.wikipedia.org/wiki/JavaScript";>JavaScript</a>-based
+<li><a href="https://en.wikipedia.org/wiki/JavaScript";>JavaScript</a>-based
 compilers and libraries include:
 <ul>
 <li><a href="http://momentjs.com/timezone/";>Moment Timezone</a> is a
@@ -321,11 +324,11 @@ It is freely available under a <abbr>BSD
 <li><a href="http://tzinfo.github.io";>TZInfo &ndash;
 Ruby Timezone Library</a>
 compiles <code><abbr>tz</abbr></code> source into
-<a href="http://www.ruby-lang.org/en/";>Ruby</a>.
+<a href="https://www.ruby-lang.org/en/";>Ruby</a>.
 It is freely available under the <abbr>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
+a <a href="https://en.wikipedia.org/wiki/Smalltalk";>Smalltalk</a> class
 library that compiles <code><abbr>tz</abbr></code> source into a time
 zone repository whose format
 is either proprietary or an <abbr>XML</abbr>-encoded
@@ -348,7 +351,7 @@ This library is freely available under t
 <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://www.gnome.org";>GNOME</a>'s Glib has
+<li><a href="https://www.gnome.org";>GNOME</a>'s Glib has
 a <code><abbr>tz</abbr></code> binary file reader written in C that
 creates a <code>GTimeZone</code> object representing sets
 of <abbr>UT</abbr> offsets.
@@ -382,7 +385,7 @@ available under a BSD-style license.</li
 <h2>Other <code><abbr>tz</abbr></code>-based time zone software</h2>
 <ul>
 <li><a href="https://foxclocks.org";>FoxClocks</a>
-is an extension for <a href="http://google.com/chrome/";>Google
+is an extension for <a href="http://www.google.com/chrome/";>Google
 Chrome</a> and for <a
 href="https://developer.mozilla.org/en-US/docs/Mozilla/Tech/Toolkit_API";>Mozilla
 Toolkit</a> applications like <a
@@ -403,15 +406,15 @@ under the <abbr>GPL</abbr>.</li>
 <li>Microsoft Windows 8.1
 and later has <code><abbr>tz</abbr></code> data and <abbr>CLDR</abbr>
 data (mentioned below) used by
-<a href="http://en.wikipedia.org/wiki/Windows_Runtime";>Windows Runtime</a>
+<a href="https://en.wikipedia.org/wiki/Windows_Runtime";>Windows Runtime</a>
 classes such as <a
-href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.globalization.datetimeformatting.datetimeformatter.aspx";><code>DateTimeFormatter</code></a>.
+href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.globalization.datetimeformatting.datetimeformatter.aspx";><code>DateTimeFormatter</code></a>.
 <a
 href="http://blogs.msdn.com/b/bclteam/archive/2007/06/07/exploring-windows-time-zones-with-system-timezoneinfo-josh-free.aspx";>Exploring
 Windows Time Zones with <code>System.TimeZoneInfo</code></a> describes
 the older, proprietary method of Microsoft Windows 2000 and later,
 which stores time zone data in the
-<a href="http://en.wikipedia.org/wiki/Windows_Registry";>Windows Registry</a>. The
+<a href="https://en.wikipedia.org/wiki/Windows_Registry";>Windows Registry</a>. The
 <a
 href="http://www.unicode.org/cldr/charts/latest/supplemental/zone_tzid.html";>Zone &rarr;
 Tzid table</a> or <a
@@ -451,10 +454,10 @@ href="http://astrocom.com";>Astro Computi
 These atlases are extensive but unreliable, as Shanks appears to have
 guessed many <abbr>UT</abbr> offsets and transitions. The atlases cite no
 sources and do not indicate which entries are guesswork.</li>
-<li><a href="http://en.wikipedia.org/wiki/HP-UX";>HP-UX</a> has a database in
+<li><a href="https://en.wikipedia.org/wiki/HP-UX";>HP-UX</a> has a database in
 its own <code>tztab</code>(4) format.</li>
 <li>Microsoft Windows has proprietary data mentioned above.</li>
-<li><a href="http://worldtimeserver.com";>World Time Server</a>
+<li><a href="http://www.worldtimeserver.com";>World Time Server</a>
 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
@@ -479,13 +482,14 @@ recent editions.
 The pictorial quality is good,
 but the maps do not indicate summer time,
 and parts of the data are a few years out of date.</li>
-<li><a href="http://worldtimezone.com";>Current time around the world
+<li><a href="http://www.worldtimezone.com";>Current time around the world
 and standard time zones map of the world</a>
 has several fancy time zone maps; it covers Russia particularly well.
 The maps' pictorial quality is not quite as good as the
 <abbr>CIA</abbr>'s
 but the maps are more up to date.</li>
-<li><a href="http://poisson.phc.unipi.it/~maggiolo/index.php/2014/01/how-much-is-time-wrong-around-the-world/";>How
+<li><a
+href="http://blog.poormansmath.net/how-much-is-time-wrong-around-the-world/";>How
 much is time wrong around the world?</a> maps the difference between
 mean solar and standard time, highlighting areas such as western China
 where the two differ greatly. It's a bit out of date, unfortunately.</li>
@@ -494,7 +498,7 @@ where the two differ greatly. It's a bit
 <ul>
 <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
+href="https://en.wikipedia.org/wiki/Shapefile";>shapefiles</a> of
 sets of <code><abbr>tz</abbr></code> regions.</li>
 <li>The <a href="https://github.com/bradfitz/latlong";>latlong package</a>
 maps geographical coordinates to a <code><abbr>tz</abbr></code> region.
@@ -517,7 +521,7 @@ world time zone boundaries distributed u
 href="http://spatialnews.geocomm.com/features/timezones/";>International
 Time Zones and Time Zone Data</a>.</li>
 <li>A ship within the <a
-href="http://en.wikipedia.org/wiki/Territorial_waters";>territorial
+href="https://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
 <abbr>UTC</abbr>&minus;12 and <abbr>UTC</abbr>+12 are each 7.5&deg;
@@ -543,11 +547,6 @@ Saving Energy</a> discusses a primary ju
 <li><a href="http://seizethedaylight.com/dst/";>A Brief
 History of Daylight Saving Time</a> summarizes some of the contentious
 history of <abbr>DST</abbr>.</li>
-<li><a href="http://toi.inrim.it/uk/toi.html";>The
-Time of Internet</a>
-describes time zones and daylight saving time,
-with diagrams.
-The time zone map is out of date, however.</li>
 <li><a href="http://www.staff.science.uu.nl/~gent0113/idl/idl.htm";>A History of
 the International Date Line</a> tells the story of the most important
 time zone boundary.</li>
@@ -619,6 +618,10 @@ with perhaps the best-documented history
 The National Physical Laboratory also maintains an <a
 href="http://www.npl.co.uk/educate-explore/what-is-time/archive-of-summer-time-dates-1916-2006";>Archive
 of Summer time dates</a>.</dd>
+<dt>United States</dt>
+<dd>The Department of Transportation's <a
+href="http://www.transportation.gov/regulations/recent-time-zone-proceedings";>Recent
+Time Zone Proceedings</a> lists changes to time zone boundaries.</dd>
 </dl>
 <h2>Precision timekeeping</h2>
 <ul>
@@ -640,7 +643,7 @@ href="http://tools.ietf.org/html/rfc4833
 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";><abbr>DHCP</abbr></a>
+href="https://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 Facts
@@ -661,7 +664,7 @@ title="International Astronomical Union"
 href="http://www.iausofa.org";><abbr
 title="Standards Of Fundamental Astronomy">SOFA</abbr></a>
 collection contains C and <a
-href="http://en.wikipedia.org/wiki/Fortran";>Fortran</a>
+href="https://en.wikipedia.org/wiki/Fortran";>Fortran</a>
 code for converting among time scales like
 <abbr title="International Atomic Time">TAI</abbr>,
 <abbr>TDB</abbr>, <abbr>TDT</abbr> and
@@ -773,13 +776,9 @@ any future changes to the rules. One sho
 local time is nine hours ahead of <abbr>UTC</abbr> and the time zone
 is called "<abbr>GMT</abbr>".</li>
 </ul>
-<h2>Related indexes</h2>
+<h2>See also</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 &ndash;
-Reference: Time</a></li>
-<li><a href="https://dir.yahoo.com/science/measurements_and_units/time";>Yahoo!
-Directory &gt; Science &gt; Measurements and Units &gt; Time</a></li>
 </ul>
 <hr>
 <address>

Index: src/lib/libc/time/zdump.c
diff -u src/lib/libc/time/zdump.c:1.41 src/lib/libc/time/zdump.c:1.42
--- src/lib/libc/time/zdump.c:1.41	Sun Jun 21 12:06:51 2015
+++ src/lib/libc/time/zdump.c	Thu Aug 13 07:21:18 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: zdump.c,v 1.41 2015/06/21 16:06:51 christos Exp $	*/
+/*	$NetBSD: zdump.c,v 1.42 2015/08/13 11:21:18 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.41 2015/06/21 16:06:51 christos Exp $");
+__RCSID("$NetBSD: zdump.c,v 1.42 2015/08/13 11:21:18 christos Exp $");
 #endif /* !defined lint */
 
 /*
@@ -284,6 +284,9 @@ static void show(timezone_t, char *, tim
 static const char *tformat(void);
 static time_t yeartot(intmax_t) ATTRIBUTE_PURE;
 
+/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
+#define is_digit(c) ((unsigned)(c) - '0' <= 9)
+
 /* Is A an alphabetic character in the C locale?  */
 static bool
 is_alpha(char a)
@@ -495,24 +498,15 @@ abbrok(const char *const abbrp, const ch
 	if (warned)
 		return;
 	cp = abbrp;
-	wp = NULL;
-	while (is_alpha(*cp))
+	while (is_alpha(*cp) || is_digit(*cp) || *cp == '-' || *cp == '+')
 		++cp;
-	if (cp - abbrp == 0)
-		wp = _("lacks alphabetic at start");
-	else if (cp - abbrp < 3)
-		wp = _("has fewer than 3 alphabetics");
+	if (cp - abbrp < 3)
+		wp = _("has fewer than 3 characters");
 	else if (cp - abbrp > 6)
-		wp = _("has more than 6 alphabetics");
-	if (wp == NULL && (*cp == '+' || *cp == '-')) {
-		++cp;
-		if ('0' <= *cp && *cp <= '9')
-			if (*cp++ == '1' && '0' <= *cp && *cp <= '4')
-				cp++;
-		if (*cp != '\0')
-			wp = _("differs from POSIX standard");
-	}
-	if (wp == NULL)
+		wp = _("has more than 6 characters");
+	else if (*cp)
+		wp = _("has characters other than ASCII alphanumerics, '-' or '+'");
+	else
 		return;
 	(void) fflush(stdout);
 	(void) fprintf(stderr,
@@ -754,7 +748,7 @@ main(int argc, char *argv[])
 }
 
 static time_t
-yeartot(const intmax_t y)
+yeartot(intmax_t y)
 {
 	intmax_t	myy, seconds, years;
 	time_t		t;

Index: src/lib/libc/time/zic.8
diff -u src/lib/libc/time/zic.8:1.25 src/lib/libc/time/zic.8:1.26
--- src/lib/libc/time/zic.8:1.25	Sun Jun 21 12:06:51 2015
+++ src/lib/libc/time/zic.8	Thu Aug 13 07:21:18 2015
@@ -1,5 +1,5 @@
-.\"	$NetBSD: zic.8,v 1.25 2015/06/21 16:06:51 christos Exp $
-.Dd October 6, 2014
+.\"	$NetBSD: zic.8,v 1.26 2015/08/13 11:21:18 christos Exp $
+.Dd August 13, 2015
 .Dt ZIC 8
 .Os
 .Sh NAME
@@ -90,12 +90,6 @@ or it contains a file name component tha
 or that starts with
 .Dq - .
 .El
-.It Fl y Ar command
-Use the given
-.Ar command
-rather than
-.Em yearistype
-when checking year types (see below).
 .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
@@ -168,27 +162,11 @@ may be used to repeat the value of the
 .Em FROM
 field.
 .It TYPE
-Gives the type of year in which the rule applies.
-If
-.Em TYPE
-is
-.Em \&-
-then the rule applies in all years between
-.Em FROM
-and
-.Em TO
-inclusive.
-If
-.Em TYPE
-is something else, then
+should be
+.Dq -
+and is present for compatibility with older versions of
 .Nm
-executes the command
-.Pp
-.Ic yearistype Ar year type
-.Pp
-to check the type of a year:
-an exit status of zero is taken to mean that the year is of the given type;
-an exit status of one is taken to mean that the year is not of the given type.
+in which it could contain year types.
 .It IN
 Names the month in which the rule takes effect.
 Month names may be abbreviated.
@@ -260,6 +238,12 @@ field
 and
 .Em s
 suffixes are not used).
+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
+.Em SAVE
+from a 10:00 standard time plus a 1:00
+.Em SAVE .
 .It LETTER/S
 Gives the
 .Dq variable part
@@ -308,6 +292,8 @@ alternatively, an amount of time to add 
 If this field is
 .Em \&-
 then standard time always applies in the time zone.
+When an amount of time is given, only the sum of standard time and
+this amount matters.
 .It FORMAT
 The format for time zone abbreviations in this time zone.
 The pair of characters
@@ -315,10 +301,25 @@ The pair of characters
 is used to show where the
 .Dq variable part
 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
+.Em \(+- hh ,
+.Em \(+- hhmm ,
+or
+.Em \(+- hhmmss ,
+using the shortest form that does not lose information, where
+.Em hh ,
+.Em mm ,
+and
+.Em ss
+are the hours, minutes, and seconds east (+) or west (\(mi) of UTC.
 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]]]
 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.
@@ -344,6 +345,11 @@ Continuation lines may contain
 information, just as zone lines do, indicating that the next line is a further
 continuation.
 .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.
+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
 For example:

Index: src/lib/libc/time/zic.c
diff -u src/lib/libc/time/zic.c:1.54 src/lib/libc/time/zic.c:1.55
--- src/lib/libc/time/zic.c:1.54	Sun Jun 21 12:06:51 2015
+++ src/lib/libc/time/zic.c	Thu Aug 13 07:21:18 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: zic.c,v 1.54 2015/06/21 16:06:51 christos Exp $	*/
+/*	$NetBSD: zic.c,v 1.55 2015/08/13 11:21:18 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.54 2015/06/21 16:06:51 christos Exp $");
+__RCSID("$NetBSD: zic.c,v 1.55 2015/08/13 11:21:18 christos Exp $");
 #endif /* !defined lint */
 
 #include "private.h"
@@ -86,6 +86,7 @@ struct zone {
 	zic_t		z_gmtoff;
 	const char *	z_rule;
 	const char *	z_format;
+	char		z_format_specifier;
 
 	zic_t		z_stdoff;
 
@@ -143,6 +144,9 @@ static bool	yearistype(int year, const c
 static int	atcomp(const void *avp, const void *bvp);
 static void	updateminmax(zic_t x);
 
+/* Bound on length of what %z can expand to.  */
+enum { PERCENT_Z_LEN_BOUND = sizeof "+995959" - 1 };
+
 static int		charcnt;
 static bool		errors;
 static bool		warnings;
@@ -152,7 +156,7 @@ static bool		leapseen;
 static zic_t		leapminyear;
 static zic_t		leapmaxyear;
 static int		linenum;
-static size_t		max_abbrvar_len;
+static size_t		max_abbrvar_len = PERCENT_Z_LEN_BOUND;
 static size_t		max_format_len;
 static zic_t		max_year;
 static zic_t		min_year;
@@ -506,7 +510,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 ] [ -y yearistype ] [ filename ... ]\n\n"
+	    "\t[ -L leapseconds ] [ filename ... ]\n\n"
 	    "Report bugs to %s.\n"),
 	  progname, progname, REPORT_BUGS_TO);
   if (status == EXIT_SUCCESS)
@@ -748,7 +752,7 @@ relname(char const *dir, char const *bas
 }
 
 static void
-dolink(const char *const fromfield, const char *const tofield)
+dolink(char const *fromfield, char const *tofield)
 {
 	char *	fromname;
 	char *	toname;
@@ -868,7 +872,7 @@ static const zic_t big_bang_time = BIG_B
 
 /* Return 1 if NAME is a directory, 0 if it's something else, -1 if trouble.  */
 static int
-itsdir(const char *const name)
+itsdir(char const *name)
 {
 	struct stat st;
 	int res = stat(name, &st);
@@ -968,7 +972,7 @@ associate(void)
 			** Note, though, that if there's no rule,
 			** a '%s' in the format is a bad thing.
 			*/
-			if (strchr(zp->z_format, '%') != 0)
+			if (zp->z_format_specifier == 's')
 				error("%s", _("%s in ruleless zone"));
 		}
 	}
@@ -1110,7 +1114,7 @@ warning(_("values over 24 hours not hand
 }
 
 static void
-inrule(char **const fields, const int nfields)
+inrule(char **fields, int nfields)
 {
 	static struct rule	r;
 
@@ -1136,7 +1140,7 @@ inrule(char **const fields, const int nf
 }
 
 static bool
-inzone(char **const fields, const int nfields)
+inzone(char **fields, int nfields)
 {
 	int	i;
 
@@ -1170,7 +1174,7 @@ _("duplicate zone name %s (file \"%s\", 
 }
 
 static bool
-inzcont(char **const fields, const int nfields)
+inzcont(char **fields, int nfields)
 {
 	if (nfields < ZONEC_MINFIELDS || nfields > ZONEC_MAXFIELDS) {
 		error(_("wrong number of fields on Zone continuation line"));
@@ -1183,6 +1187,7 @@ static bool
 inzsub(char **const fields, const int nfields, const int iscont)
 {
 	char *		cp;
+	char *		cp1;
 	static struct zone	z;
 	int		i_gmtoff, i_rule, i_format;
 	int		i_untilyear, i_untilmonth;
@@ -1214,13 +1219,21 @@ inzsub(char **const fields, const int nf
 	z.z_linenum = linenum;
 	z.z_gmtoff = gethms(fields[i_gmtoff], _("invalid UT offset"), true);
 	if ((cp = strchr(fields[i_format], '%')) != 0) {
-		if (*++cp != 's' || strchr(cp, '%') != 0) {
+		if ((*++cp != 's' && *cp != 'z') || strchr(cp, '%')
+		    || strchr(fields[i_format], '/')) {
 			error(_("invalid abbreviation format"));
 			return false;
 		}
 	}
 	z.z_rule = ecpyalloc(fields[i_rule]);
-	z.z_format = ecpyalloc(fields[i_format]);
+	z.z_format = cp1 = ecpyalloc(fields[i_format]);
+	z.z_format_specifier = cp ? *cp : '\0';
+	if (z.z_format_specifier == 'z') {
+	  if (noise)
+	    warning(_("format '%s' not handled by pre-2015 versions of zic"),
+		    z.z_format);
+	  cp1[cp - fields[i_format]] = 's';
+	}
 	if (max_format_len < strlen(z.z_format))
 		max_format_len = strlen(z.z_format);
 	hasuntil = nfields > i_untilyear;
@@ -1259,7 +1272,7 @@ inzsub(char **const fields, const int nf
 }
 
 static void
-inleap(char **const fields, const int nfields)
+inleap(char **fields, int nfields)
 {
 	const char *		cp;
 	const struct lookup *	lp;
@@ -1387,9 +1400,9 @@ inlink(char **const fields, const int nf
 }
 
 static void
-rulesub(struct rule *const rp, const char *const loyearp,
-    const char *const hiyearp, const char *const typep,
-    const char *const monthp, const char *const dayp, const char *const timep)
+rulesub(struct rule *rp, const char *loyearp, const char *hiyearp,
+    const char *typep, const char *monthp, const char *dayp,
+    const char *timep)
 {
 	const struct lookup *	lp;
 	const char *		cp;
@@ -1904,19 +1917,59 @@ writezone(const char *const name, const 
 	free(fullname);
 }
 
+static char const *
+abbroffset(char *buf, zic_t offset)
+{
+	char sign = '+';
+	int seconds, minutes;
+
+	if (offset < 0) {
+		offset = -offset;
+		sign = '-';
+	}
+
+	seconds = offset % SECSPERMIN;
+	offset /= SECSPERMIN;
+	minutes = offset % MINSPERHOUR;
+	offset /= MINSPERHOUR;
+	if (100 <= offset) {
+		error(_("%%z UTC offset magnitude exceeds 99:59:59"));
+		return "%z";
+	} else {
+		char *p = buf;
+		*p++ = sign;
+		*p++ = '0' + offset / 10;
+		*p++ = '0' + offset % 10;
+		if (minutes | seconds) {
+			*p++ = '0' + minutes / 10;
+			*p++ = '0' + minutes % 10;
+			if (seconds) {
+				*p++ = '0' + seconds / 10;
+				*p++ = '0' + seconds % 10;
+			}
+		}
+		*p = '\0';
+		return buf;
+	}
+}
+
 static size_t
-doabbr(char *const abbr, const int abbrlen, const char *const format,
-    const char *const letters, bool isdst, bool doquotes)
+doabbr(char *abbr, int abbrlen, struct zone const *zp, const char *letters,
+    bool isdst, bool doquotes)
 {
 	char *	cp;
 	char *	slashp;
 	size_t	len;
+	char const *format = zp->z_format;
 
 	slashp = strchr(format, '/');
 	if (slashp == NULL) {
-		if (letters == NULL)
-			(void) strlcpy(abbr, format, abbrlen);
-		else	(void) snprintf(abbr, abbrlen, format, letters);
+		char letterbuf[PERCENT_Z_LEN_BOUND + 1];
+		if (zp->z_format_specifier == 'z')
+			letters = abbroffset(letterbuf, -zp->z_gmtoff);
+		else if (!letters)
+			letters = "%s";
+		(void) snprintf(abbr, abbrlen, format, letters);
 	} else if (isdst) {
 		(void) strlcpy(abbr, slashp + 1, abbrlen);
 	} else {
@@ -2142,7 +2195,7 @@ stringzone(char *result, const int resul
 	if (stdrp == NULL && (zp->z_nrules != 0 || zp->z_stdoff != 0))
 		return -1;
 	abbrvar = (stdrp == NULL) ? "" : stdrp->r_abbrvar;
-	len = doabbr(result, resultlen, zp->z_format, abbrvar, false, true);
+	len = doabbr(result, resultlen, zp, abbrvar, false, true);
 	offsetlen = stringoffset(result + len, -zp->z_gmtoff);
 	if (! offsetlen) {
 		result[0] = '\0';
@@ -2151,8 +2204,7 @@ stringzone(char *result, const int resul
 	len += offsetlen;
 	if (dstrp == NULL)
 		return compat;
-	len += doabbr(result + len, resultlen - len, zp->z_format,
-	    dstrp->r_abbrvar, true, true);
+	len += doabbr(result + len, resultlen - len, zp, dstrp->r_abbrvar, true, true);
 	if (dstrp->r_stdoff != SECSPERMIN * MINSPERHOUR) {
 		offsetlen = stringoffset(result + len,
 		    -(zp->z_gmtoff + dstrp->r_stdoff));
@@ -2183,7 +2235,7 @@ stringzone(char *result, const int resul
 }
 
 static void
-outzone(const struct zone *const zpfirst, const int zonecount)
+outzone(const struct zone *zpfirst, int zonecount)
 {
 	const struct zone *	zp;
 	struct rule *		rp;
@@ -2323,8 +2375,8 @@ outzone(const struct zone *const zpfirst
 		startoff = zp->z_gmtoff;
 		if (zp->z_nrules == 0) {
 			stdoff = zp->z_stdoff;
-			doabbr(startbuf, max_abbr_len + 1, zp->z_format,
-			        NULL, stdoff != 0, false);
+			doabbr(startbuf, max_abbr_len + 1, zp,
+			    NULL, stdoff != 0, false);
 			type = addtype(oadd(zp->z_gmtoff, stdoff),
 				startbuf, stdoff != 0, startttisstd,
 				startttisgmt);
@@ -2391,6 +2443,16 @@ outzone(const struct zone *const zpfirst
 					if (k < 0 || jtime < ktime) {
 						k = j;
 						ktime = jtime;
+					} else if (jtime == ktime) {
+					  char const *dup_rules_msg =
+					    _("two rules for same instant");
+					  eats(zp->z_filename, zp->z_linenum,
+					       rp->r_filename, rp->r_linenum);
+					  warning("%s", dup_rules_msg);
+					  rp = &zp->z_rules[k];
+					  eats(zp->z_filename, zp->z_linenum,
+					       rp->r_filename, rp->r_linenum);
+					  error("%s", dup_rules_msg);
 					}
 				}
 				if (k < 0)
@@ -2408,7 +2470,7 @@ outzone(const struct zone *const zpfirst
 							stdoff);
 						doabbr(startbuf,
 							max_abbr_len + 1,
-							zp->z_format,
+							zp,
 							rp->r_abbrvar,
 							rp->r_stdoff != 0,
 							false);
@@ -2419,7 +2481,7 @@ outzone(const struct zone *const zpfirst
 						stdoff)) {
 							doabbr(startbuf,
 								max_abbr_len + 1,
-								zp->z_format,
+								zp,
 								rp->r_abbrvar,
 								rp->r_stdoff !=
 								0,
@@ -2428,7 +2490,7 @@ outzone(const struct zone *const zpfirst
 				}
 				eats(zp->z_filename, zp->z_linenum,
 					rp->r_filename, rp->r_linenum);
-				doabbr(ab, max_abbr_len+1, zp->z_format, rp->r_abbrvar,
+				doabbr(ab, max_abbr_len + 1, zp, rp->r_abbrvar,
 					rp->r_stdoff != 0, false);
 				offset = oadd(zp->z_gmtoff, rp->r_stdoff);
 				type = addtype(offset, ab, rp->r_stdoff != 0,
@@ -2510,7 +2572,7 @@ error(_("can't determine time zone abbre
 }
 
 static void
-addtt(const zic_t starttime, int type)
+addtt(zic_t starttime, int type)
 {
 	if (starttime <= big_bang_time ||
 		(timecnt == 1 && attypes[0].at < big_bang_time)) {
@@ -2621,7 +2683,7 @@ adjleap(void)
 }
 
 static bool
-yearistype(const int year, const char *const type)
+yearistype(int year, const char *type)
 {
 	static char *	buf;
 	int		result;
@@ -2719,7 +2781,7 @@ itsabbr(const char *abbr, const char *wo
 }
 
 static ATTRIBUTE_PURE const struct lookup *
-byword(const char *const word, const struct lookup *const table)
+byword(const char *word, const struct lookup *table)
 {
 	const struct lookup *	foundlp;
 	const struct lookup *	lp;
@@ -2791,7 +2853,7 @@ time_overflow(void)
 }
 
 static ATTRIBUTE_PURE zic_t
-oadd(const zic_t t1, const zic_t t2)
+oadd(zic_t t1, zic_t t2)
 {
 	if (t1 < 0 ? t2 < ZIC_MIN - t1 : ZIC_MAX - t1 < t2)
 		time_overflow();
@@ -2799,7 +2861,7 @@ oadd(const zic_t t1, const zic_t t2)
 }
 
 static ATTRIBUTE_PURE zic_t
-tadd(const zic_t t1, const zic_t t2)
+tadd(zic_t t1, zic_t t2)
 {
 	if (t1 < 0) {
 		if (t2 < min_time - t1) {
@@ -2823,7 +2885,7 @@ tadd(const zic_t t1, const zic_t t2)
 */
 
 static zic_t
-rpytime(const struct rule *const rp, const zic_t wantedy)
+rpytime(const struct rule *rp, zic_t wantedy)
 {
 	int	m, i;
 	zic_t	dayoff;			/* with a nod to Margaret O. */
@@ -2904,7 +2966,7 @@ will not work with pre-2004 versions of 
 }
 
 static void
-newabbr(const char *const string)
+newabbr(const char *string)
 {
 	int	i;
 
@@ -2912,27 +2974,15 @@ newabbr(const char *const string)
 		const char *	cp;
 		const char *	mp;
 
-		/*
-		** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics
-		** optionally followed by a + or - and a number from 1 to 14.
-		*/
 		cp = string;
 		mp = NULL;
-		while (is_alpha(*cp))
+		while (is_alpha(*cp) || ('0' <= *cp && *cp <= '9')
+		       || *cp == '-' || *cp == '+')
 				++cp;
-		if (cp - string == 0)
-mp = _("time zone abbreviation lacks alphabetic at start");
 		if (noise && cp - string < 3)
-mp = _("time zone abbreviation has fewer than 3 alphabetics");
+		  mp = _("time zone abbreviation has fewer than 3 characters");
 		if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
-mp = _("time zone abbreviation has too many alphabetics");
-		if (mp == NULL && (*cp == '+' || *cp == '-')) {
-			++cp;
-			if (is_digit(*cp))
-					if (*cp++ == '1' &&
-						*cp >= '0' && *cp <= '4')
-							++cp;
-		}
+		  mp = _("time zone abbreviation has too many characters");
 		if (*cp != '\0')
 mp = _("time zone abbreviation differs from POSIX standard");
 		if (mp != NULL)

Reply via email to