History log of /netbsd-current/lib/libc/time/localtime.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.143 11-Mar-2024 christos

add casts for compat code where time_t is 32 bits.


# 1.142 07-Mar-2024 christos

pass lint on sparc64 where int_fast32_t is long.


# 1.141 17-Feb-2024 christos

Sync with tzcode2024a:
Release 2024a - 2024-02-01 09:28:56 -0800

Changes to code

The FROM and TO columns of Rule lines can no longer be "minimum"
or an abbreviation of "minimum", because TZif files do not support
DST rules that extend into the indefinite past - although these
rules were supported when TZif files had only 32-bit data, this
stopped working when 64-bit TZif files were introduced in 1995.
This should not be a problem for realistic data, since DST was
first used in the 20th century. As a transition aid, FROM columns
like "minimum" are now diagnosed and then treated as if they were
the year 1900; this should suffice for TZif files on old systems
with only 32-bit time_t, and it is more compatible with bugs in
2023c-and-earlier localtime.c. (Problem reported by Yoshito
Umaoka.)

localtime and related functions no longer mishandle some
timestamps that occur about 400 years after a switch to a time
zone with a DST schedule. In 2023d data this problem was visible
for some timestamps in November 2422, November 2822, etc. in
America/Ciudad_Juarez. (Problem reported by Gilmore Davidson.)

strftime %s now uses tm_gmtoff if available. (Problem and draft
patch reported by Dag-Erling Sm��rgrav.)

Changes to build procedure

The leap-seconds.list file is now copied from the IERS instead of
from its downstream counterpart at NIST, as the IERS version is
now in the public domain too and tends to be more up-to-date.
(Thanks to Martin Burnicki for liaisoning with the IERS.)

Changes to documentation

The strftime man page documents which struct tm members affect
which conversion specs, and that tzset is called. (Problems
reported by Robert Elz and Steve Summit.)


# 1.140 20-Jan-2024 christos

Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.


# 1.139 23-Dec-2023 christos

Import tzcode 2023d:

localtime.c no longer mishandles TZif files that contain a single
transition into a DST regime. Previously, it incorrectly assumed
DST was in effect before the transition too. (Thanks to Alois
Treindl for debugging help.)

localtime.c's timeoff no longer collides with OpenBSD 7.4.

The C code now uses _Generic only if __STDC_VERSION__ says the
compiler is C11 or later.

tzselect now optionally reads zonenow.tab, to simplify when
configuring only for timestamps dated from now on.

tzselect no longer creates temporary files.

tzselect no longer mishandles the following:

Spaces and most other special characters in BUGEMAIL, PACKAGE,
TZDIR, and VERSION.

TZ strings when using mawk 1.4.3, which mishandles regular
expressions of the form /X{2,}/.

ISO 6709 coordinates when using an awk that lacks the GNU
extension of newlines in -v option-arguments.

Non UTF-8 locales when using an iconv command that lacks the GNU
//TRANSLIT extension.

zic no longer mishandles data for Palestine after the year 2075.
Previously, it incorrectly omitted post-2075 transitions that are
predicted for just before and just after Ramadan. (Thanks to Ken
Murchison for debugging help.)

zic now works again on Linux 2.6.16 and 2.6.17 (2006).


# 1.138 16-Sep-2023 christos

Update tzcode from 2022g to 2023c:

Release 2023c - 2023-03-28 12:42:14 -0700

Release 2023b - 2023-03-23 19:50:38 -0700

Release 2023a - 2023-03-22 12:39:33 -0700

Changes to code

You can now tell tzselect local time, to simplify later choices.
Select the 'time' option in its first prompt.

You can now compile with -DTZNAME_MAXIMUM=N to limit time zone
abbreviations to N bytes (default 255). The reference runtime
library now rejects POSIX-style TZ strings that contain longer
abbreviations, treating them as UTC. Previously the limit was
platform dependent and abbreviations were silently truncated to
16 bytes even when the limit was greater than 16.

The code by default is now designed for C99 or later. To build in
a C89 environment, compile with -DPORT_TO_C89. To support C89
callers of the tzcode library, compile with -DSUPPORT_C89. The
two new macros are transitional aids planned to be removed in a
future version, when C99 or later will be required.

The code now builds again on pre-C99 platforms, if you compile
with -DPORT_TO_C89. This fixes a bug introduced in 2022f.

On C23-compatible platforms tzcode no longer uses syntax like
'static [[noreturn]] void usage(void);'. Instead, it uses
'[[noreturn]] static void usage(void);' as strict C23 requires.
(Problem reported by Houge Langley.)

The code's functions now constrain their arguments with the C
'restrict' keyword consistently with their documentation.
This may allow future optimizations.

zdump again builds standalone with ckdadd and without setenv,
fixing a bug introduced in 2022g. (Problem reported by panic.)

leapseconds.awk can now process a leap seconds file that never
expires; this might be useful if leap seconds are discontinued.

Changes to commentary

tz-link.html has a new section "Coordinating with governments and
distributors". (Thanks to Neil Fuller for some of the text.)

To improve tzselect diagnostics, zone1970.tab's comments column is
now limited to countries that have multiple timezones.

Note that leap seconds are planned to be discontinued by 2035.


# 1.137 15-Jan-2023 christos

Apply 9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f for C23 attribute compliance.
Requested by Jan-Benedict Glaw.


Revision tags: netbsd-10-base
# 1.136 11-Dec-2022 christos

branches: 1.136.2;
Merge in 2022g:

Although tzcode still works with C89, bugs found in recent routine
maintenance indicate that bitrot has set in and that in practice
C89 is no longer used to build tzcode. As it is a maintenance
burden, support for C89 is planned to be removed soon. Instead,
please use compilers compatible with C99, C11, C17, or C23.

timegm, which tzcode implemented in 1989, will finally be
standardized 34 years later as part of C23, so timegm is now
supported even if STD_INSPIRED is not defined.

Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
(Problem reported by ��o��n Tr���n C��ng Danh.)

Fix bug in zic on hosts where malloc(0) yields NULL on success.
(Problem reported by Tim McBrayer for AIX 6.1.)

Fix zic configuration to avoid linkage failures on some platforms.
(Problems reported by Gilmore Davidson and Igor Ivanov.)

Work around MS-Windows nmake incompatibility with POSIX.
(Problem reported by Manuela Friedrich.)

Port mktime and strftime to debugging platforms where accessing
uninitialized data has undefined behavior (strftime problem
reported by Robert Elz).

Check more carefully for unlikely integer overflows, preferring
C23 <stdckdint.h> to overflow checking by hand, as the latter has
had obscure bugs.


# 1.135 29-Oct-2022 christos

Update to tzcode2022f

Changes to code

zic now supports links to links regardless of input line order.
For example, if Australia/Sydney is a Zone, the lines
Link Australia/Canberra Australia/ACT
Link Australia/Sydney Australia/Canberra
now work correctly, even though the shell commands
ln Australia/Canberra Australia/ACT
ln Australia/Sydney Australia/Canberra
would fail because the first command attempts to use a link
Australia/Canberra that does not exist until after the second
command is executed. Previously, zic had unspecified behavior if
a Link line's target was another link, and zic often misbehaved if
a Link line's target was a later Link line.

Fix line number in zic's diagnostic for a link to a link.

Fix a bug that caused localtime to mishandle timestamps starting
in the year 2438 when reading data generated by 'zic -b fat' when
distant-future DST transitions occur at times given in standard
time or in UT, not the usual case of local time. This occurs when
the corresponding .zi Rule lines specify DST transitions with TO
columns of 'max' and AT columns that end in 's' or 'u'. The
number 2438 comes from the 32-bit limit in the year 2038, plus the
400-year Gregorian cycle. (Problem reported by Bradley White.)

On glibc 2.34 and later, which optionally supports 64-bit time_t
on platforms like x86 where time_t was traditionally 32 bits,
default time_t to 64 instead of 32 bits. This lets functions like
localtime support timestamps after the year 2038, and fixes
year-2038 problems in zic when accessing files dated after 2038.
To continue to limit time_t to 32 bits on these platforms, use
"make CFLAGS='-D_TIME_BITS=32'".

In C code, do not enable large-file support on platforms like AIX
and macOS that no longer need it now that tzcode does not use
off_t or related functions like 'stat'. Large-file support is
still enabled by default on GNU/Linux, as it is needed for 64-bit
time_t support.

In C code, prefer C23 keywords to pre-C23 macros for alignof,
bool, false, and true. Also, use the following C23 features if
available: __has_include, unreachable.

zic no longer works around Qt bug 53071, as the relevant Qt
releases have been out of support since 2019. This change affects
only fat TZif files, as thin files never had the workaround.

zdump no longer modifies the environ vector when compiled on
platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
This avoid undefined behavior on POSIX platforms.


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.142 07-Mar-2024 christos

pass lint on sparc64 where int_fast32_t is long.


# 1.141 17-Feb-2024 christos

Sync with tzcode2024a:
Release 2024a - 2024-02-01 09:28:56 -0800

Changes to code

The FROM and TO columns of Rule lines can no longer be "minimum"
or an abbreviation of "minimum", because TZif files do not support
DST rules that extend into the indefinite past - although these
rules were supported when TZif files had only 32-bit data, this
stopped working when 64-bit TZif files were introduced in 1995.
This should not be a problem for realistic data, since DST was
first used in the 20th century. As a transition aid, FROM columns
like "minimum" are now diagnosed and then treated as if they were
the year 1900; this should suffice for TZif files on old systems
with only 32-bit time_t, and it is more compatible with bugs in
2023c-and-earlier localtime.c. (Problem reported by Yoshito
Umaoka.)

localtime and related functions no longer mishandle some
timestamps that occur about 400 years after a switch to a time
zone with a DST schedule. In 2023d data this problem was visible
for some timestamps in November 2422, November 2822, etc. in
America/Ciudad_Juarez. (Problem reported by Gilmore Davidson.)

strftime %s now uses tm_gmtoff if available. (Problem and draft
patch reported by Dag-Erling Sm��rgrav.)

Changes to build procedure

The leap-seconds.list file is now copied from the IERS instead of
from its downstream counterpart at NIST, as the IERS version is
now in the public domain too and tends to be more up-to-date.
(Thanks to Martin Burnicki for liaisoning with the IERS.)

Changes to documentation

The strftime man page documents which struct tm members affect
which conversion specs, and that tzset is called. (Problems
reported by Robert Elz and Steve Summit.)


# 1.140 20-Jan-2024 christos

Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.


# 1.139 23-Dec-2023 christos

Import tzcode 2023d:

localtime.c no longer mishandles TZif files that contain a single
transition into a DST regime. Previously, it incorrectly assumed
DST was in effect before the transition too. (Thanks to Alois
Treindl for debugging help.)

localtime.c's timeoff no longer collides with OpenBSD 7.4.

The C code now uses _Generic only if __STDC_VERSION__ says the
compiler is C11 or later.

tzselect now optionally reads zonenow.tab, to simplify when
configuring only for timestamps dated from now on.

tzselect no longer creates temporary files.

tzselect no longer mishandles the following:

Spaces and most other special characters in BUGEMAIL, PACKAGE,
TZDIR, and VERSION.

TZ strings when using mawk 1.4.3, which mishandles regular
expressions of the form /X{2,}/.

ISO 6709 coordinates when using an awk that lacks the GNU
extension of newlines in -v option-arguments.

Non UTF-8 locales when using an iconv command that lacks the GNU
//TRANSLIT extension.

zic no longer mishandles data for Palestine after the year 2075.
Previously, it incorrectly omitted post-2075 transitions that are
predicted for just before and just after Ramadan. (Thanks to Ken
Murchison for debugging help.)

zic now works again on Linux 2.6.16 and 2.6.17 (2006).


# 1.138 16-Sep-2023 christos

Update tzcode from 2022g to 2023c:

Release 2023c - 2023-03-28 12:42:14 -0700

Release 2023b - 2023-03-23 19:50:38 -0700

Release 2023a - 2023-03-22 12:39:33 -0700

Changes to code

You can now tell tzselect local time, to simplify later choices.
Select the 'time' option in its first prompt.

You can now compile with -DTZNAME_MAXIMUM=N to limit time zone
abbreviations to N bytes (default 255). The reference runtime
library now rejects POSIX-style TZ strings that contain longer
abbreviations, treating them as UTC. Previously the limit was
platform dependent and abbreviations were silently truncated to
16 bytes even when the limit was greater than 16.

The code by default is now designed for C99 or later. To build in
a C89 environment, compile with -DPORT_TO_C89. To support C89
callers of the tzcode library, compile with -DSUPPORT_C89. The
two new macros are transitional aids planned to be removed in a
future version, when C99 or later will be required.

The code now builds again on pre-C99 platforms, if you compile
with -DPORT_TO_C89. This fixes a bug introduced in 2022f.

On C23-compatible platforms tzcode no longer uses syntax like
'static [[noreturn]] void usage(void);'. Instead, it uses
'[[noreturn]] static void usage(void);' as strict C23 requires.
(Problem reported by Houge Langley.)

The code's functions now constrain their arguments with the C
'restrict' keyword consistently with their documentation.
This may allow future optimizations.

zdump again builds standalone with ckdadd and without setenv,
fixing a bug introduced in 2022g. (Problem reported by panic.)

leapseconds.awk can now process a leap seconds file that never
expires; this might be useful if leap seconds are discontinued.

Changes to commentary

tz-link.html has a new section "Coordinating with governments and
distributors". (Thanks to Neil Fuller for some of the text.)

To improve tzselect diagnostics, zone1970.tab's comments column is
now limited to countries that have multiple timezones.

Note that leap seconds are planned to be discontinued by 2035.


# 1.137 15-Jan-2023 christos

Apply 9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f for C23 attribute compliance.
Requested by Jan-Benedict Glaw.


Revision tags: netbsd-10-base
# 1.136 11-Dec-2022 christos

branches: 1.136.2;
Merge in 2022g:

Although tzcode still works with C89, bugs found in recent routine
maintenance indicate that bitrot has set in and that in practice
C89 is no longer used to build tzcode. As it is a maintenance
burden, support for C89 is planned to be removed soon. Instead,
please use compilers compatible with C99, C11, C17, or C23.

timegm, which tzcode implemented in 1989, will finally be
standardized 34 years later as part of C23, so timegm is now
supported even if STD_INSPIRED is not defined.

Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
(Problem reported by ��o��n Tr���n C��ng Danh.)

Fix bug in zic on hosts where malloc(0) yields NULL on success.
(Problem reported by Tim McBrayer for AIX 6.1.)

Fix zic configuration to avoid linkage failures on some platforms.
(Problems reported by Gilmore Davidson and Igor Ivanov.)

Work around MS-Windows nmake incompatibility with POSIX.
(Problem reported by Manuela Friedrich.)

Port mktime and strftime to debugging platforms where accessing
uninitialized data has undefined behavior (strftime problem
reported by Robert Elz).

Check more carefully for unlikely integer overflows, preferring
C23 <stdckdint.h> to overflow checking by hand, as the latter has
had obscure bugs.


# 1.135 29-Oct-2022 christos

Update to tzcode2022f

Changes to code

zic now supports links to links regardless of input line order.
For example, if Australia/Sydney is a Zone, the lines
Link Australia/Canberra Australia/ACT
Link Australia/Sydney Australia/Canberra
now work correctly, even though the shell commands
ln Australia/Canberra Australia/ACT
ln Australia/Sydney Australia/Canberra
would fail because the first command attempts to use a link
Australia/Canberra that does not exist until after the second
command is executed. Previously, zic had unspecified behavior if
a Link line's target was another link, and zic often misbehaved if
a Link line's target was a later Link line.

Fix line number in zic's diagnostic for a link to a link.

Fix a bug that caused localtime to mishandle timestamps starting
in the year 2438 when reading data generated by 'zic -b fat' when
distant-future DST transitions occur at times given in standard
time or in UT, not the usual case of local time. This occurs when
the corresponding .zi Rule lines specify DST transitions with TO
columns of 'max' and AT columns that end in 's' or 'u'. The
number 2438 comes from the 32-bit limit in the year 2038, plus the
400-year Gregorian cycle. (Problem reported by Bradley White.)

On glibc 2.34 and later, which optionally supports 64-bit time_t
on platforms like x86 where time_t was traditionally 32 bits,
default time_t to 64 instead of 32 bits. This lets functions like
localtime support timestamps after the year 2038, and fixes
year-2038 problems in zic when accessing files dated after 2038.
To continue to limit time_t to 32 bits on these platforms, use
"make CFLAGS='-D_TIME_BITS=32'".

In C code, do not enable large-file support on platforms like AIX
and macOS that no longer need it now that tzcode does not use
off_t or related functions like 'stat'. Large-file support is
still enabled by default on GNU/Linux, as it is needed for 64-bit
time_t support.

In C code, prefer C23 keywords to pre-C23 macros for alignof,
bool, false, and true. Also, use the following C23 features if
available: __has_include, unreachable.

zic no longer works around Qt bug 53071, as the relevant Qt
releases have been out of support since 2019. This change affects
only fat TZif files, as thin files never had the workaround.

zdump no longer modifies the environ vector when compiled on
platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
This avoid undefined behavior on POSIX platforms.


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.141 17-Feb-2024 christos

Sync with tzcode2024a:
Release 2024a - 2024-02-01 09:28:56 -0800

Changes to code

The FROM and TO columns of Rule lines can no longer be "minimum"
or an abbreviation of "minimum", because TZif files do not support
DST rules that extend into the indefinite past - although these
rules were supported when TZif files had only 32-bit data, this
stopped working when 64-bit TZif files were introduced in 1995.
This should not be a problem for realistic data, since DST was
first used in the 20th century. As a transition aid, FROM columns
like "minimum" are now diagnosed and then treated as if they were
the year 1900; this should suffice for TZif files on old systems
with only 32-bit time_t, and it is more compatible with bugs in
2023c-and-earlier localtime.c. (Problem reported by Yoshito
Umaoka.)

localtime and related functions no longer mishandle some
timestamps that occur about 400 years after a switch to a time
zone with a DST schedule. In 2023d data this problem was visible
for some timestamps in November 2422, November 2822, etc. in
America/Ciudad_Juarez. (Problem reported by Gilmore Davidson.)

strftime %s now uses tm_gmtoff if available. (Problem and draft
patch reported by Dag-Erling Sm��rgrav.)

Changes to build procedure

The leap-seconds.list file is now copied from the IERS instead of
from its downstream counterpart at NIST, as the IERS version is
now in the public domain too and tends to be more up-to-date.
(Thanks to Martin Burnicki for liaisoning with the IERS.)

Changes to documentation

The strftime man page documents which struct tm members affect
which conversion specs, and that tzset is called. (Problems
reported by Robert Elz and Steve Summit.)


# 1.140 20-Jan-2024 christos

Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.


# 1.139 23-Dec-2023 christos

Import tzcode 2023d:

localtime.c no longer mishandles TZif files that contain a single
transition into a DST regime. Previously, it incorrectly assumed
DST was in effect before the transition too. (Thanks to Alois
Treindl for debugging help.)

localtime.c's timeoff no longer collides with OpenBSD 7.4.

The C code now uses _Generic only if __STDC_VERSION__ says the
compiler is C11 or later.

tzselect now optionally reads zonenow.tab, to simplify when
configuring only for timestamps dated from now on.

tzselect no longer creates temporary files.

tzselect no longer mishandles the following:

Spaces and most other special characters in BUGEMAIL, PACKAGE,
TZDIR, and VERSION.

TZ strings when using mawk 1.4.3, which mishandles regular
expressions of the form /X{2,}/.

ISO 6709 coordinates when using an awk that lacks the GNU
extension of newlines in -v option-arguments.

Non UTF-8 locales when using an iconv command that lacks the GNU
//TRANSLIT extension.

zic no longer mishandles data for Palestine after the year 2075.
Previously, it incorrectly omitted post-2075 transitions that are
predicted for just before and just after Ramadan. (Thanks to Ken
Murchison for debugging help.)

zic now works again on Linux 2.6.16 and 2.6.17 (2006).


# 1.138 16-Sep-2023 christos

Update tzcode from 2022g to 2023c:

Release 2023c - 2023-03-28 12:42:14 -0700

Release 2023b - 2023-03-23 19:50:38 -0700

Release 2023a - 2023-03-22 12:39:33 -0700

Changes to code

You can now tell tzselect local time, to simplify later choices.
Select the 'time' option in its first prompt.

You can now compile with -DTZNAME_MAXIMUM=N to limit time zone
abbreviations to N bytes (default 255). The reference runtime
library now rejects POSIX-style TZ strings that contain longer
abbreviations, treating them as UTC. Previously the limit was
platform dependent and abbreviations were silently truncated to
16 bytes even when the limit was greater than 16.

The code by default is now designed for C99 or later. To build in
a C89 environment, compile with -DPORT_TO_C89. To support C89
callers of the tzcode library, compile with -DSUPPORT_C89. The
two new macros are transitional aids planned to be removed in a
future version, when C99 or later will be required.

The code now builds again on pre-C99 platforms, if you compile
with -DPORT_TO_C89. This fixes a bug introduced in 2022f.

On C23-compatible platforms tzcode no longer uses syntax like
'static [[noreturn]] void usage(void);'. Instead, it uses
'[[noreturn]] static void usage(void);' as strict C23 requires.
(Problem reported by Houge Langley.)

The code's functions now constrain their arguments with the C
'restrict' keyword consistently with their documentation.
This may allow future optimizations.

zdump again builds standalone with ckdadd and without setenv,
fixing a bug introduced in 2022g. (Problem reported by panic.)

leapseconds.awk can now process a leap seconds file that never
expires; this might be useful if leap seconds are discontinued.

Changes to commentary

tz-link.html has a new section "Coordinating with governments and
distributors". (Thanks to Neil Fuller for some of the text.)

To improve tzselect diagnostics, zone1970.tab's comments column is
now limited to countries that have multiple timezones.

Note that leap seconds are planned to be discontinued by 2035.


# 1.137 15-Jan-2023 christos

Apply 9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f for C23 attribute compliance.
Requested by Jan-Benedict Glaw.


Revision tags: netbsd-10-base
# 1.136 11-Dec-2022 christos

branches: 1.136.2;
Merge in 2022g:

Although tzcode still works with C89, bugs found in recent routine
maintenance indicate that bitrot has set in and that in practice
C89 is no longer used to build tzcode. As it is a maintenance
burden, support for C89 is planned to be removed soon. Instead,
please use compilers compatible with C99, C11, C17, or C23.

timegm, which tzcode implemented in 1989, will finally be
standardized 34 years later as part of C23, so timegm is now
supported even if STD_INSPIRED is not defined.

Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
(Problem reported by ��o��n Tr���n C��ng Danh.)

Fix bug in zic on hosts where malloc(0) yields NULL on success.
(Problem reported by Tim McBrayer for AIX 6.1.)

Fix zic configuration to avoid linkage failures on some platforms.
(Problems reported by Gilmore Davidson and Igor Ivanov.)

Work around MS-Windows nmake incompatibility with POSIX.
(Problem reported by Manuela Friedrich.)

Port mktime and strftime to debugging platforms where accessing
uninitialized data has undefined behavior (strftime problem
reported by Robert Elz).

Check more carefully for unlikely integer overflows, preferring
C23 <stdckdint.h> to overflow checking by hand, as the latter has
had obscure bugs.


# 1.135 29-Oct-2022 christos

Update to tzcode2022f

Changes to code

zic now supports links to links regardless of input line order.
For example, if Australia/Sydney is a Zone, the lines
Link Australia/Canberra Australia/ACT
Link Australia/Sydney Australia/Canberra
now work correctly, even though the shell commands
ln Australia/Canberra Australia/ACT
ln Australia/Sydney Australia/Canberra
would fail because the first command attempts to use a link
Australia/Canberra that does not exist until after the second
command is executed. Previously, zic had unspecified behavior if
a Link line's target was another link, and zic often misbehaved if
a Link line's target was a later Link line.

Fix line number in zic's diagnostic for a link to a link.

Fix a bug that caused localtime to mishandle timestamps starting
in the year 2438 when reading data generated by 'zic -b fat' when
distant-future DST transitions occur at times given in standard
time or in UT, not the usual case of local time. This occurs when
the corresponding .zi Rule lines specify DST transitions with TO
columns of 'max' and AT columns that end in 's' or 'u'. The
number 2438 comes from the 32-bit limit in the year 2038, plus the
400-year Gregorian cycle. (Problem reported by Bradley White.)

On glibc 2.34 and later, which optionally supports 64-bit time_t
on platforms like x86 where time_t was traditionally 32 bits,
default time_t to 64 instead of 32 bits. This lets functions like
localtime support timestamps after the year 2038, and fixes
year-2038 problems in zic when accessing files dated after 2038.
To continue to limit time_t to 32 bits on these platforms, use
"make CFLAGS='-D_TIME_BITS=32'".

In C code, do not enable large-file support on platforms like AIX
and macOS that no longer need it now that tzcode does not use
off_t or related functions like 'stat'. Large-file support is
still enabled by default on GNU/Linux, as it is needed for 64-bit
time_t support.

In C code, prefer C23 keywords to pre-C23 macros for alignof,
bool, false, and true. Also, use the following C23 features if
available: __has_include, unreachable.

zic no longer works around Qt bug 53071, as the relevant Qt
releases have been out of support since 2019. This change affects
only fat TZif files, as thin files never had the workaround.

zdump no longer modifies the environ vector when compiled on
platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
This avoid undefined behavior on POSIX platforms.


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.140 20-Jan-2024 christos

Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.


# 1.139 23-Dec-2023 christos

Import tzcode 2023d:

localtime.c no longer mishandles TZif files that contain a single
transition into a DST regime. Previously, it incorrectly assumed
DST was in effect before the transition too. (Thanks to Alois
Treindl for debugging help.)

localtime.c's timeoff no longer collides with OpenBSD 7.4.

The C code now uses _Generic only if __STDC_VERSION__ says the
compiler is C11 or later.

tzselect now optionally reads zonenow.tab, to simplify when
configuring only for timestamps dated from now on.

tzselect no longer creates temporary files.

tzselect no longer mishandles the following:

Spaces and most other special characters in BUGEMAIL, PACKAGE,
TZDIR, and VERSION.

TZ strings when using mawk 1.4.3, which mishandles regular
expressions of the form /X{2,}/.

ISO 6709 coordinates when using an awk that lacks the GNU
extension of newlines in -v option-arguments.

Non UTF-8 locales when using an iconv command that lacks the GNU
//TRANSLIT extension.

zic no longer mishandles data for Palestine after the year 2075.
Previously, it incorrectly omitted post-2075 transitions that are
predicted for just before and just after Ramadan. (Thanks to Ken
Murchison for debugging help.)

zic now works again on Linux 2.6.16 and 2.6.17 (2006).


# 1.138 16-Sep-2023 christos

Update tzcode from 2022g to 2023c:

Release 2023c - 2023-03-28 12:42:14 -0700

Release 2023b - 2023-03-23 19:50:38 -0700

Release 2023a - 2023-03-22 12:39:33 -0700

Changes to code

You can now tell tzselect local time, to simplify later choices.
Select the 'time' option in its first prompt.

You can now compile with -DTZNAME_MAXIMUM=N to limit time zone
abbreviations to N bytes (default 255). The reference runtime
library now rejects POSIX-style TZ strings that contain longer
abbreviations, treating them as UTC. Previously the limit was
platform dependent and abbreviations were silently truncated to
16 bytes even when the limit was greater than 16.

The code by default is now designed for C99 or later. To build in
a C89 environment, compile with -DPORT_TO_C89. To support C89
callers of the tzcode library, compile with -DSUPPORT_C89. The
two new macros are transitional aids planned to be removed in a
future version, when C99 or later will be required.

The code now builds again on pre-C99 platforms, if you compile
with -DPORT_TO_C89. This fixes a bug introduced in 2022f.

On C23-compatible platforms tzcode no longer uses syntax like
'static [[noreturn]] void usage(void);'. Instead, it uses
'[[noreturn]] static void usage(void);' as strict C23 requires.
(Problem reported by Houge Langley.)

The code's functions now constrain their arguments with the C
'restrict' keyword consistently with their documentation.
This may allow future optimizations.

zdump again builds standalone with ckdadd and without setenv,
fixing a bug introduced in 2022g. (Problem reported by panic.)

leapseconds.awk can now process a leap seconds file that never
expires; this might be useful if leap seconds are discontinued.

Changes to commentary

tz-link.html has a new section "Coordinating with governments and
distributors". (Thanks to Neil Fuller for some of the text.)

To improve tzselect diagnostics, zone1970.tab's comments column is
now limited to countries that have multiple timezones.

Note that leap seconds are planned to be discontinued by 2035.


# 1.137 15-Jan-2023 christos

Apply 9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f for C23 attribute compliance.
Requested by Jan-Benedict Glaw.


Revision tags: netbsd-10-base
# 1.136 11-Dec-2022 christos

branches: 1.136.2;
Merge in 2022g:

Although tzcode still works with C89, bugs found in recent routine
maintenance indicate that bitrot has set in and that in practice
C89 is no longer used to build tzcode. As it is a maintenance
burden, support for C89 is planned to be removed soon. Instead,
please use compilers compatible with C99, C11, C17, or C23.

timegm, which tzcode implemented in 1989, will finally be
standardized 34 years later as part of C23, so timegm is now
supported even if STD_INSPIRED is not defined.

Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
(Problem reported by ��o��n Tr���n C��ng Danh.)

Fix bug in zic on hosts where malloc(0) yields NULL on success.
(Problem reported by Tim McBrayer for AIX 6.1.)

Fix zic configuration to avoid linkage failures on some platforms.
(Problems reported by Gilmore Davidson and Igor Ivanov.)

Work around MS-Windows nmake incompatibility with POSIX.
(Problem reported by Manuela Friedrich.)

Port mktime and strftime to debugging platforms where accessing
uninitialized data has undefined behavior (strftime problem
reported by Robert Elz).

Check more carefully for unlikely integer overflows, preferring
C23 <stdckdint.h> to overflow checking by hand, as the latter has
had obscure bugs.


# 1.135 29-Oct-2022 christos

Update to tzcode2022f

Changes to code

zic now supports links to links regardless of input line order.
For example, if Australia/Sydney is a Zone, the lines
Link Australia/Canberra Australia/ACT
Link Australia/Sydney Australia/Canberra
now work correctly, even though the shell commands
ln Australia/Canberra Australia/ACT
ln Australia/Sydney Australia/Canberra
would fail because the first command attempts to use a link
Australia/Canberra that does not exist until after the second
command is executed. Previously, zic had unspecified behavior if
a Link line's target was another link, and zic often misbehaved if
a Link line's target was a later Link line.

Fix line number in zic's diagnostic for a link to a link.

Fix a bug that caused localtime to mishandle timestamps starting
in the year 2438 when reading data generated by 'zic -b fat' when
distant-future DST transitions occur at times given in standard
time or in UT, not the usual case of local time. This occurs when
the corresponding .zi Rule lines specify DST transitions with TO
columns of 'max' and AT columns that end in 's' or 'u'. The
number 2438 comes from the 32-bit limit in the year 2038, plus the
400-year Gregorian cycle. (Problem reported by Bradley White.)

On glibc 2.34 and later, which optionally supports 64-bit time_t
on platforms like x86 where time_t was traditionally 32 bits,
default time_t to 64 instead of 32 bits. This lets functions like
localtime support timestamps after the year 2038, and fixes
year-2038 problems in zic when accessing files dated after 2038.
To continue to limit time_t to 32 bits on these platforms, use
"make CFLAGS='-D_TIME_BITS=32'".

In C code, do not enable large-file support on platforms like AIX
and macOS that no longer need it now that tzcode does not use
off_t or related functions like 'stat'. Large-file support is
still enabled by default on GNU/Linux, as it is needed for 64-bit
time_t support.

In C code, prefer C23 keywords to pre-C23 macros for alignof,
bool, false, and true. Also, use the following C23 features if
available: __has_include, unreachable.

zic no longer works around Qt bug 53071, as the relevant Qt
releases have been out of support since 2019. This change affects
only fat TZif files, as thin files never had the workaround.

zdump no longer modifies the environ vector when compiled on
platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
This avoid undefined behavior on POSIX platforms.


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.139 23-Dec-2023 christos

Import tzcode 2023d:

localtime.c no longer mishandles TZif files that contain a single
transition into a DST regime. Previously, it incorrectly assumed
DST was in effect before the transition too. (Thanks to Alois
Treindl for debugging help.)

localtime.c's timeoff no longer collides with OpenBSD 7.4.

The C code now uses _Generic only if __STDC_VERSION__ says the
compiler is C11 or later.

tzselect now optionally reads zonenow.tab, to simplify when
configuring only for timestamps dated from now on.

tzselect no longer creates temporary files.

tzselect no longer mishandles the following:

Spaces and most other special characters in BUGEMAIL, PACKAGE,
TZDIR, and VERSION.

TZ strings when using mawk 1.4.3, which mishandles regular
expressions of the form /X{2,}/.

ISO 6709 coordinates when using an awk that lacks the GNU
extension of newlines in -v option-arguments.

Non UTF-8 locales when using an iconv command that lacks the GNU
//TRANSLIT extension.

zic no longer mishandles data for Palestine after the year 2075.
Previously, it incorrectly omitted post-2075 transitions that are
predicted for just before and just after Ramadan. (Thanks to Ken
Murchison for debugging help.)

zic now works again on Linux 2.6.16 and 2.6.17 (2006).


# 1.138 16-Sep-2023 christos

Update tzcode from 2022g to 2023c:

Release 2023c - 2023-03-28 12:42:14 -0700

Release 2023b - 2023-03-23 19:50:38 -0700

Release 2023a - 2023-03-22 12:39:33 -0700

Changes to code

You can now tell tzselect local time, to simplify later choices.
Select the 'time' option in its first prompt.

You can now compile with -DTZNAME_MAXIMUM=N to limit time zone
abbreviations to N bytes (default 255). The reference runtime
library now rejects POSIX-style TZ strings that contain longer
abbreviations, treating them as UTC. Previously the limit was
platform dependent and abbreviations were silently truncated to
16 bytes even when the limit was greater than 16.

The code by default is now designed for C99 or later. To build in
a C89 environment, compile with -DPORT_TO_C89. To support C89
callers of the tzcode library, compile with -DSUPPORT_C89. The
two new macros are transitional aids planned to be removed in a
future version, when C99 or later will be required.

The code now builds again on pre-C99 platforms, if you compile
with -DPORT_TO_C89. This fixes a bug introduced in 2022f.

On C23-compatible platforms tzcode no longer uses syntax like
'static [[noreturn]] void usage(void);'. Instead, it uses
'[[noreturn]] static void usage(void);' as strict C23 requires.
(Problem reported by Houge Langley.)

The code's functions now constrain their arguments with the C
'restrict' keyword consistently with their documentation.
This may allow future optimizations.

zdump again builds standalone with ckdadd and without setenv,
fixing a bug introduced in 2022g. (Problem reported by panic.)

leapseconds.awk can now process a leap seconds file that never
expires; this might be useful if leap seconds are discontinued.

Changes to commentary

tz-link.html has a new section "Coordinating with governments and
distributors". (Thanks to Neil Fuller for some of the text.)

To improve tzselect diagnostics, zone1970.tab's comments column is
now limited to countries that have multiple timezones.

Note that leap seconds are planned to be discontinued by 2035.


# 1.137 15-Jan-2023 christos

Apply 9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f for C23 attribute compliance.
Requested by Jan-Benedict Glaw.


Revision tags: netbsd-10-base
# 1.136 11-Dec-2022 christos

branches: 1.136.2;
Merge in 2022g:

Although tzcode still works with C89, bugs found in recent routine
maintenance indicate that bitrot has set in and that in practice
C89 is no longer used to build tzcode. As it is a maintenance
burden, support for C89 is planned to be removed soon. Instead,
please use compilers compatible with C99, C11, C17, or C23.

timegm, which tzcode implemented in 1989, will finally be
standardized 34 years later as part of C23, so timegm is now
supported even if STD_INSPIRED is not defined.

Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
(Problem reported by ��o��n Tr���n C��ng Danh.)

Fix bug in zic on hosts where malloc(0) yields NULL on success.
(Problem reported by Tim McBrayer for AIX 6.1.)

Fix zic configuration to avoid linkage failures on some platforms.
(Problems reported by Gilmore Davidson and Igor Ivanov.)

Work around MS-Windows nmake incompatibility with POSIX.
(Problem reported by Manuela Friedrich.)

Port mktime and strftime to debugging platforms where accessing
uninitialized data has undefined behavior (strftime problem
reported by Robert Elz).

Check more carefully for unlikely integer overflows, preferring
C23 <stdckdint.h> to overflow checking by hand, as the latter has
had obscure bugs.


# 1.135 29-Oct-2022 christos

Update to tzcode2022f

Changes to code

zic now supports links to links regardless of input line order.
For example, if Australia/Sydney is a Zone, the lines
Link Australia/Canberra Australia/ACT
Link Australia/Sydney Australia/Canberra
now work correctly, even though the shell commands
ln Australia/Canberra Australia/ACT
ln Australia/Sydney Australia/Canberra
would fail because the first command attempts to use a link
Australia/Canberra that does not exist until after the second
command is executed. Previously, zic had unspecified behavior if
a Link line's target was another link, and zic often misbehaved if
a Link line's target was a later Link line.

Fix line number in zic's diagnostic for a link to a link.

Fix a bug that caused localtime to mishandle timestamps starting
in the year 2438 when reading data generated by 'zic -b fat' when
distant-future DST transitions occur at times given in standard
time or in UT, not the usual case of local time. This occurs when
the corresponding .zi Rule lines specify DST transitions with TO
columns of 'max' and AT columns that end in 's' or 'u'. The
number 2438 comes from the 32-bit limit in the year 2038, plus the
400-year Gregorian cycle. (Problem reported by Bradley White.)

On glibc 2.34 and later, which optionally supports 64-bit time_t
on platforms like x86 where time_t was traditionally 32 bits,
default time_t to 64 instead of 32 bits. This lets functions like
localtime support timestamps after the year 2038, and fixes
year-2038 problems in zic when accessing files dated after 2038.
To continue to limit time_t to 32 bits on these platforms, use
"make CFLAGS='-D_TIME_BITS=32'".

In C code, do not enable large-file support on platforms like AIX
and macOS that no longer need it now that tzcode does not use
off_t or related functions like 'stat'. Large-file support is
still enabled by default on GNU/Linux, as it is needed for 64-bit
time_t support.

In C code, prefer C23 keywords to pre-C23 macros for alignof,
bool, false, and true. Also, use the following C23 features if
available: __has_include, unreachable.

zic no longer works around Qt bug 53071, as the relevant Qt
releases have been out of support since 2019. This change affects
only fat TZif files, as thin files never had the workaround.

zdump no longer modifies the environ vector when compiled on
platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
This avoid undefined behavior on POSIX platforms.


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.138 16-Sep-2023 christos

Update tzcode from 2022g to 2023c:

Release 2023c - 2023-03-28 12:42:14 -0700

Release 2023b - 2023-03-23 19:50:38 -0700

Release 2023a - 2023-03-22 12:39:33 -0700

Changes to code

You can now tell tzselect local time, to simplify later choices.
Select the 'time' option in its first prompt.

You can now compile with -DTZNAME_MAXIMUM=N to limit time zone
abbreviations to N bytes (default 255). The reference runtime
library now rejects POSIX-style TZ strings that contain longer
abbreviations, treating them as UTC. Previously the limit was
platform dependent and abbreviations were silently truncated to
16 bytes even when the limit was greater than 16.

The code by default is now designed for C99 or later. To build in
a C89 environment, compile with -DPORT_TO_C89. To support C89
callers of the tzcode library, compile with -DSUPPORT_C89. The
two new macros are transitional aids planned to be removed in a
future version, when C99 or later will be required.

The code now builds again on pre-C99 platforms, if you compile
with -DPORT_TO_C89. This fixes a bug introduced in 2022f.

On C23-compatible platforms tzcode no longer uses syntax like
'static [[noreturn]] void usage(void);'. Instead, it uses
'[[noreturn]] static void usage(void);' as strict C23 requires.
(Problem reported by Houge Langley.)

The code's functions now constrain their arguments with the C
'restrict' keyword consistently with their documentation.
This may allow future optimizations.

zdump again builds standalone with ckdadd and without setenv,
fixing a bug introduced in 2022g. (Problem reported by panic.)

leapseconds.awk can now process a leap seconds file that never
expires; this might be useful if leap seconds are discontinued.

Changes to commentary

tz-link.html has a new section "Coordinating with governments and
distributors". (Thanks to Neil Fuller for some of the text.)

To improve tzselect diagnostics, zone1970.tab's comments column is
now limited to countries that have multiple timezones.

Note that leap seconds are planned to be discontinued by 2035.


# 1.137 15-Jan-2023 christos

Apply 9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f for C23 attribute compliance.
Requested by Jan-Benedict Glaw.


Revision tags: netbsd-10-base
# 1.136 11-Dec-2022 christos

branches: 1.136.2;
Merge in 2022g:

Although tzcode still works with C89, bugs found in recent routine
maintenance indicate that bitrot has set in and that in practice
C89 is no longer used to build tzcode. As it is a maintenance
burden, support for C89 is planned to be removed soon. Instead,
please use compilers compatible with C99, C11, C17, or C23.

timegm, which tzcode implemented in 1989, will finally be
standardized 34 years later as part of C23, so timegm is now
supported even if STD_INSPIRED is not defined.

Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
(Problem reported by ��o��n Tr���n C��ng Danh.)

Fix bug in zic on hosts where malloc(0) yields NULL on success.
(Problem reported by Tim McBrayer for AIX 6.1.)

Fix zic configuration to avoid linkage failures on some platforms.
(Problems reported by Gilmore Davidson and Igor Ivanov.)

Work around MS-Windows nmake incompatibility with POSIX.
(Problem reported by Manuela Friedrich.)

Port mktime and strftime to debugging platforms where accessing
uninitialized data has undefined behavior (strftime problem
reported by Robert Elz).

Check more carefully for unlikely integer overflows, preferring
C23 <stdckdint.h> to overflow checking by hand, as the latter has
had obscure bugs.


# 1.135 29-Oct-2022 christos

Update to tzcode2022f

Changes to code

zic now supports links to links regardless of input line order.
For example, if Australia/Sydney is a Zone, the lines
Link Australia/Canberra Australia/ACT
Link Australia/Sydney Australia/Canberra
now work correctly, even though the shell commands
ln Australia/Canberra Australia/ACT
ln Australia/Sydney Australia/Canberra
would fail because the first command attempts to use a link
Australia/Canberra that does not exist until after the second
command is executed. Previously, zic had unspecified behavior if
a Link line's target was another link, and zic often misbehaved if
a Link line's target was a later Link line.

Fix line number in zic's diagnostic for a link to a link.

Fix a bug that caused localtime to mishandle timestamps starting
in the year 2438 when reading data generated by 'zic -b fat' when
distant-future DST transitions occur at times given in standard
time or in UT, not the usual case of local time. This occurs when
the corresponding .zi Rule lines specify DST transitions with TO
columns of 'max' and AT columns that end in 's' or 'u'. The
number 2438 comes from the 32-bit limit in the year 2038, plus the
400-year Gregorian cycle. (Problem reported by Bradley White.)

On glibc 2.34 and later, which optionally supports 64-bit time_t
on platforms like x86 where time_t was traditionally 32 bits,
default time_t to 64 instead of 32 bits. This lets functions like
localtime support timestamps after the year 2038, and fixes
year-2038 problems in zic when accessing files dated after 2038.
To continue to limit time_t to 32 bits on these platforms, use
"make CFLAGS='-D_TIME_BITS=32'".

In C code, do not enable large-file support on platforms like AIX
and macOS that no longer need it now that tzcode does not use
off_t or related functions like 'stat'. Large-file support is
still enabled by default on GNU/Linux, as it is needed for 64-bit
time_t support.

In C code, prefer C23 keywords to pre-C23 macros for alignof,
bool, false, and true. Also, use the following C23 features if
available: __has_include, unreachable.

zic no longer works around Qt bug 53071, as the relevant Qt
releases have been out of support since 2019. This change affects
only fat TZif files, as thin files never had the workaround.

zdump no longer modifies the environ vector when compiled on
platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
This avoid undefined behavior on POSIX platforms.


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.137 15-Jan-2023 christos

Apply 9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f for C23 attribute compliance.
Requested by Jan-Benedict Glaw.


Revision tags: netbsd-10-base
# 1.136 11-Dec-2022 christos

Merge in 2022g:

Although tzcode still works with C89, bugs found in recent routine
maintenance indicate that bitrot has set in and that in practice
C89 is no longer used to build tzcode. As it is a maintenance
burden, support for C89 is planned to be removed soon. Instead,
please use compilers compatible with C99, C11, C17, or C23.

timegm, which tzcode implemented in 1989, will finally be
standardized 34 years later as part of C23, so timegm is now
supported even if STD_INSPIRED is not defined.

Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
(Problem reported by ��o��n Tr���n C��ng Danh.)

Fix bug in zic on hosts where malloc(0) yields NULL on success.
(Problem reported by Tim McBrayer for AIX 6.1.)

Fix zic configuration to avoid linkage failures on some platforms.
(Problems reported by Gilmore Davidson and Igor Ivanov.)

Work around MS-Windows nmake incompatibility with POSIX.
(Problem reported by Manuela Friedrich.)

Port mktime and strftime to debugging platforms where accessing
uninitialized data has undefined behavior (strftime problem
reported by Robert Elz).

Check more carefully for unlikely integer overflows, preferring
C23 <stdckdint.h> to overflow checking by hand, as the latter has
had obscure bugs.


# 1.135 29-Oct-2022 christos

Update to tzcode2022f

Changes to code

zic now supports links to links regardless of input line order.
For example, if Australia/Sydney is a Zone, the lines
Link Australia/Canberra Australia/ACT
Link Australia/Sydney Australia/Canberra
now work correctly, even though the shell commands
ln Australia/Canberra Australia/ACT
ln Australia/Sydney Australia/Canberra
would fail because the first command attempts to use a link
Australia/Canberra that does not exist until after the second
command is executed. Previously, zic had unspecified behavior if
a Link line's target was another link, and zic often misbehaved if
a Link line's target was a later Link line.

Fix line number in zic's diagnostic for a link to a link.

Fix a bug that caused localtime to mishandle timestamps starting
in the year 2438 when reading data generated by 'zic -b fat' when
distant-future DST transitions occur at times given in standard
time or in UT, not the usual case of local time. This occurs when
the corresponding .zi Rule lines specify DST transitions with TO
columns of 'max' and AT columns that end in 's' or 'u'. The
number 2438 comes from the 32-bit limit in the year 2038, plus the
400-year Gregorian cycle. (Problem reported by Bradley White.)

On glibc 2.34 and later, which optionally supports 64-bit time_t
on platforms like x86 where time_t was traditionally 32 bits,
default time_t to 64 instead of 32 bits. This lets functions like
localtime support timestamps after the year 2038, and fixes
year-2038 problems in zic when accessing files dated after 2038.
To continue to limit time_t to 32 bits on these platforms, use
"make CFLAGS='-D_TIME_BITS=32'".

In C code, do not enable large-file support on platforms like AIX
and macOS that no longer need it now that tzcode does not use
off_t or related functions like 'stat'. Large-file support is
still enabled by default on GNU/Linux, as it is needed for 64-bit
time_t support.

In C code, prefer C23 keywords to pre-C23 macros for alignof,
bool, false, and true. Also, use the following C23 features if
available: __has_include, unreachable.

zic no longer works around Qt bug 53071, as the relevant Qt
releases have been out of support since 2019. This change affects
only fat TZif files, as thin files never had the workaround.

zdump no longer modifies the environ vector when compiled on
platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
This avoid undefined behavior on POSIX platforms.


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.136 11-Dec-2022 christos

Merge in 2022g:

Although tzcode still works with C89, bugs found in recent routine
maintenance indicate that bitrot has set in and that in practice
C89 is no longer used to build tzcode. As it is a maintenance
burden, support for C89 is planned to be removed soon. Instead,
please use compilers compatible with C99, C11, C17, or C23.

timegm, which tzcode implemented in 1989, will finally be
standardized 34 years later as part of C23, so timegm is now
supported even if STD_INSPIRED is not defined.

Fix bug in zdump's tzalloc emulation on hosts that lack tm_zone.
(Problem reported by ��o��n Tr���n C��ng Danh.)

Fix bug in zic on hosts where malloc(0) yields NULL on success.
(Problem reported by Tim McBrayer for AIX 6.1.)

Fix zic configuration to avoid linkage failures on some platforms.
(Problems reported by Gilmore Davidson and Igor Ivanov.)

Work around MS-Windows nmake incompatibility with POSIX.
(Problem reported by Manuela Friedrich.)

Port mktime and strftime to debugging platforms where accessing
uninitialized data has undefined behavior (strftime problem
reported by Robert Elz).

Check more carefully for unlikely integer overflows, preferring
C23 <stdckdint.h> to overflow checking by hand, as the latter has
had obscure bugs.


# 1.135 29-Oct-2022 christos

Update to tzcode2022f

Changes to code

zic now supports links to links regardless of input line order.
For example, if Australia/Sydney is a Zone, the lines
Link Australia/Canberra Australia/ACT
Link Australia/Sydney Australia/Canberra
now work correctly, even though the shell commands
ln Australia/Canberra Australia/ACT
ln Australia/Sydney Australia/Canberra
would fail because the first command attempts to use a link
Australia/Canberra that does not exist until after the second
command is executed. Previously, zic had unspecified behavior if
a Link line's target was another link, and zic often misbehaved if
a Link line's target was a later Link line.

Fix line number in zic's diagnostic for a link to a link.

Fix a bug that caused localtime to mishandle timestamps starting
in the year 2438 when reading data generated by 'zic -b fat' when
distant-future DST transitions occur at times given in standard
time or in UT, not the usual case of local time. This occurs when
the corresponding .zi Rule lines specify DST transitions with TO
columns of 'max' and AT columns that end in 's' or 'u'. The
number 2438 comes from the 32-bit limit in the year 2038, plus the
400-year Gregorian cycle. (Problem reported by Bradley White.)

On glibc 2.34 and later, which optionally supports 64-bit time_t
on platforms like x86 where time_t was traditionally 32 bits,
default time_t to 64 instead of 32 bits. This lets functions like
localtime support timestamps after the year 2038, and fixes
year-2038 problems in zic when accessing files dated after 2038.
To continue to limit time_t to 32 bits on these platforms, use
"make CFLAGS='-D_TIME_BITS=32'".

In C code, do not enable large-file support on platforms like AIX
and macOS that no longer need it now that tzcode does not use
off_t or related functions like 'stat'. Large-file support is
still enabled by default on GNU/Linux, as it is needed for 64-bit
time_t support.

In C code, prefer C23 keywords to pre-C23 macros for alignof,
bool, false, and true. Also, use the following C23 features if
available: __has_include, unreachable.

zic no longer works around Qt bug 53071, as the relevant Qt
releases have been out of support since 2019. This change affects
only fat TZif files, as thin files never had the workaround.

zdump no longer modifies the environ vector when compiled on
platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
This avoid undefined behavior on POSIX platforms.


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.135 29-Oct-2022 christos

Update to tzcode2022f

Changes to code

zic now supports links to links regardless of input line order.
For example, if Australia/Sydney is a Zone, the lines
Link Australia/Canberra Australia/ACT
Link Australia/Sydney Australia/Canberra
now work correctly, even though the shell commands
ln Australia/Canberra Australia/ACT
ln Australia/Sydney Australia/Canberra
would fail because the first command attempts to use a link
Australia/Canberra that does not exist until after the second
command is executed. Previously, zic had unspecified behavior if
a Link line's target was another link, and zic often misbehaved if
a Link line's target was a later Link line.

Fix line number in zic's diagnostic for a link to a link.

Fix a bug that caused localtime to mishandle timestamps starting
in the year 2438 when reading data generated by 'zic -b fat' when
distant-future DST transitions occur at times given in standard
time or in UT, not the usual case of local time. This occurs when
the corresponding .zi Rule lines specify DST transitions with TO
columns of 'max' and AT columns that end in 's' or 'u'. The
number 2438 comes from the 32-bit limit in the year 2038, plus the
400-year Gregorian cycle. (Problem reported by Bradley White.)

On glibc 2.34 and later, which optionally supports 64-bit time_t
on platforms like x86 where time_t was traditionally 32 bits,
default time_t to 64 instead of 32 bits. This lets functions like
localtime support timestamps after the year 2038, and fixes
year-2038 problems in zic when accessing files dated after 2038.
To continue to limit time_t to 32 bits on these platforms, use
"make CFLAGS='-D_TIME_BITS=32'".

In C code, do not enable large-file support on platforms like AIX
and macOS that no longer need it now that tzcode does not use
off_t or related functions like 'stat'. Large-file support is
still enabled by default on GNU/Linux, as it is needed for 64-bit
time_t support.

In C code, prefer C23 keywords to pre-C23 macros for alignof,
bool, false, and true. Also, use the following C23 features if
available: __has_include, unreachable.

zic no longer works around Qt bug 53071, as the relevant Qt
releases have been out of support since 2019. This change affects
only fat TZif files, as thin files never had the workaround.

zdump no longer modifies the environ vector when compiled on
platforms lacking tm_zone or when compiled with -DUSE_LTZ=0.
This avoid undefined behavior on POSIX platforms.


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.134 16-Aug-2022 christos

Welcome to 2022b:

zic has a new option '-R @N' to output explicit transitions < N.
(Need suggested by Almaz Mingaleev.)

'zic -r @N' no longer outputs bad data when N < first transition.
(Problem introduced in 2021d and reported by Peter Krefting.)

zic now checks its input for NUL bytes and unterminated lines, and
now supports input line lengths up to 2048 (not 512) bytes.

gmtime and related code now use the abbreviation "UTC" not "GMT".
POSIX is being revised to require this.

When tzset and related functions set vestigial static variables
like tzname, they now prefer specified timestamps to unspecified ones.
(Problem reported by Almaz Mingaleev.)

zic no longer complains "can't determine time zone abbreviation to
use just after until time" when a transition to a new standard
time occurs simultanously with the first DST fallback transition.


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.133 25-Mar-2022 rillig

localtime.c: fix theoretical syntax error

If NetBSD were built with -DHAVE_MALLOC_ERRNO=0, the previous code would
have resulted in a compile error due to the extra '}'. Fix this by
copying the upstream code.

No binary change.


# 1.132 25-Mar-2022 rillig

localtime.c: reduce unnecessary diff to upstream

No binary change.


# 1.131 25-Mar-2022 rillig

localtime.c: take indentation style from upstream

This reduces the diff to upstream.

No binary change.


# 1.130 25-Mar-2022 rillig

localtime.c: add back storage class 'register'

This reduces the differences to the upstream code.

No binary change.


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.129 24-Mar-2022 christos

put back the 2022a changes and fix the misplaced brace.


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.128 23-Mar-2022 christos

revert changes from 2022a for now until I figure out what's wrong.


# 1.127 22-Mar-2022 christos

welcome to tzcode-2022a

Changes to code

Fix bug when mktime gets confused by truncated TZif files with
unspecified local time. (Problem reported by Almaz Mingaleev.)

Fix bug when 32-bit time_t code reads malformed 64-bit TZif data.
(Problem reported by Christos Zoulas.)

When reading a version 2 or later TZif file, the TZif reader now
validates the version 1 header and data block only enough to skip
over them, as recommended by RFC 8536 section 4. Also, the TZif
reader no longer mistakenly attempts to parse a version 1 TZIf
file header as a TZ string.

zdump -v now outputs "(localtime failed)" and "(gmtime failed)"
when local time and UT cannot be determined for a timestamp.


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.126 05-Dec-2021 christos

PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)
we want to load the timezone data using the same structs they were saved as.
Introduce __time_t which is always 64 bits and make the minimal changes for
this to work. Yes, it is ugly.


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.125 27-Oct-2021 christos

fix problem with uninitialized variable on malformed 32 bit time.


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.124 22-Oct-2021 christos

Change to code and documentation from 2021a -> 2021e

Release 2021e - 2021-10-21 18:41:00 -0700

Changes to code

none


Release 2021d - 2021-10-15 13:48:18 -0700

Changes to code

'zic -r' now uses "-00" time zone abbreviations for intervals
with UT offsets that are unspecified due to -r truncation.
This implements a change in draft Internet RFC 8536bis.


Release 2021c - 2021-10-01 14:21:49 -0700

Changes to code

Fix a bug in 'zic -b fat' that caused old timestamps to be
mishandled in 32-bit-only readers (problem reported by Daniel
Fischer).

Changes to documentation

Distribute the SECURITY file (problem reported by Andreas Radke).


Release 2021b - 2021-09-24 16:23:00 -0700

Changes to maintenance procedure

The new file SECURITY covers how to report security-related bugs.

Several backward-compatibility links have been moved to the
'backward' file. These links, which range from Africa/Addis_Ababa
to Pacific/Saipan, are only for compatibility with now-obsolete
guidelines suggesting an entry for every ISO 3166 code.
The intercontinental convenience links Asia/Istanbul and
Europe/Nicosia have also been moved to 'backward'.

Changes to code

zic now creates each output file or link atomically,
possibly by creating a temporary file and then renaming it.
This avoids races where a TZ setting would temporarily stop
working while zic was installing a replacement file or link.

zic -L no longer omits the POSIX TZ string in its output.
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
seconds error than with an hour error, so zic -L no longer
truncates output in this way.

Instead, when zic -L is given the "Expires" directive, it now
outputs the expiration by appending a no-change entry to the leap
second table. Although this should work well with most TZif
readers, it does not conform to Internet RFC 8536 and some pickier
clients (including tzdb 2017c through 2021a) reject it, so
"Expires" directives are currently disabled by default. To enable
them, set the EXPIRES_LINE Makefile variable. If a TZif file uses
this new feature it is marked with a new TZif version number 4,
a format intended to be documented in a successor to RFC 8536.

zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
information.

The TZif reader now allows the leap second table to begin with a
correction other than -1 or +1, and to contain adjacent
transitions with equal corrections. This supports TZif version 4.

The TZif reader now lets leap seconds occur less than 28 days
apart. This supports possible future TZif extensions.

Fix bug that caused 'localtime' etc. to crash when TZ was
set to a all-year DST string like "EST5EDT4,0/0,J365/25" that does
not conform to POSIX but does conform to Internet RFC 8536.

Fix another bug that caused 'localtime' etc. to crash when TZ was
set to a POSIX-conforming but unusual TZ string like
"EST5EDT4,0/0,J365/0", where almost all the year is DST.

Fix yet another bug that caused 'localtime' etc. to mishandle slim
TZif files containing leap seconds after the last explicit
transition in the table, or when handling far-future timestamps
in slim TZif files lacking leap seconds.

Fix localtime misbehavior involving positive leap seconds.
This change affects only behavior for "right" system time,
which contains leap seconds, and only if the UT offset is
not a multiple of 60 seconds when a positive leap second occurs.
(No such timezone exists in tzdb, luckily.) Without the fix,
the timestamp was ambiguous during a positive leap second.
With the fix, any seconds occurring after a positive leap second
and within the same localtime minute are counted through 60, not
through 59; their UT offset (tm_gmtoff) is the same as before.
Here is how the fix affects timestamps in a timezone with UT
offset +01:23:45 (5025 seconds) and with a positive leap second at
1972-06-30 23:59:60 UTC (78796800):

time_t without the fix with the fix
78796800 1972-07-01 01:23:45 1972-07-01 01:23:45 (leap second)
78796801 1972-07-01 01:23:45 1972-07-01 01:23:46
...
78796815 1972-07-01 01:23:59 1972-07-01 01:23:60
78796816 1972-07-01 01:24:00 1972-07-01 01:24:00

Fix an unlikely bug that caused 'localtime' etc. to misbehave if
civil time changes a few seconds before time_t wraps around, when
leap seconds are enabled.

Fix bug in zic -r; in some cases, the dummy time type after the
last time transition disagreed with the TZ string, contrary to
Internet RFC 8563 section 3.3.

Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
leap second that has a nonpositive correction.

zic -r now reports an error if given rolling leap seconds, as this
usage has never generally worked and is evidently unused.

zic now generates a POSIX-conforming TZ string for TZif files
where all-year DST is predicted for the indefinite future.
For example, for all-year Eastern Daylight Time, zic now generates
"XXX3EDT4,0/0,J365/23" where it previously generated
"EST5EDT,0/0,J365/25" or "". (Thanks to Michael Deckers for
noting the possibility of POSIX conformance.)

zic.c no longer requires sys/wait.h (thanks to spazmodius for
noting it wasn't needed).

When reading slim TZif files, zdump no longer mishandles leap
seconds on the rare platforms where time_t counts leap seconds,
fixing a bug introduced in 2014g.

zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)

zdump's -c and -t options are now consistently inclusive for the
lower time bound and exclusive for the upper. Formerly they were
inconsistent. (Confusion noted by Martin Burnicki.)

Changes to build procedure

You can now compile with -DHAVE_MALLOC_ERRNO=0 to port to
non-POSIX hosts where malloc doesn't set errno.
(Problem reported by Jan Engelhardt.)

Changes to documentation

tzfile.5 better matches a draft successor to RFC 8536
<https://datatracker.ietf.org/doc/draft-murchison-rfc8536bis/01/>.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.123 25-May-2020 christos

Bring in 2020a


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.122 03-Jul-2019 christos

Sync with 2019b:

zic's new -b option supports a way to control data bloat and to
test for year-2038 bugs in software that reads TZif files.
'zic -b fat' and 'zic -b slim' generate larger and smaller output;
for example, changing from fat to slim shrinks the Europe/London
file from 3648 to 1599 bytes, saving about 56%. Fat and slim
files represent the same set of timestamps and use the same TZif
format as documented in tzfile(5) and in Internet RFC 8536.
Fat format attempts to work around bugs or incompatibilities in
older software, notably software that mishandles 64-bit TZif data
or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
Slim format is more efficient and does not work around 64-bit bugs
or obsolete TZ strings. Currently zic defaults to fat format
unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
out-of-the-box default is intended to change in future releases
as the buggy software often mishandles timestamps anyway.

zic no longer treats a set of rules ending in 2037 specially.
Previously, zic assumed that such a ruleset meant that future
timestamps could not be predicted, and therefore omitted a
POSIX-like TZ string in the TZif output. The old behavior is no
longer needed for current tzdata, and caused problems with newlib
when used with older tzdata (reported by David Gauchard).

zic no longer generates some artifact transitions. For example,
Europe/London no longer has a no-op transition in January 1996.


Revision tags: phil-wifi-20190609
# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

branches: 1.112.2;
Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.121 17-Apr-2019 christos

Pick up the latest matching (most recent) entry instead of the first one.

This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019

XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.


# 1.120 08-Apr-2019 christos

The typecnt refers the to ttis array and the timecnt refers to the type array.
The types array can have 0 elements (i.e. timecnt == 0), but the ttis array
needs to have one element (typecnt >= 1). Need to revisit and take into
account the types array.


# 1.119 07-Apr-2019 christos

only need to initialize the first type.


# 1.118 07-Apr-2019 christos

Initialize the default timezone a bit more so that tzgetname(3) works.


# 1.117 04-Apr-2019 christos

Make strftime_{l,z} re-entrant and always require a non-NULL timezone to be
passed in so that we can use the current timezone in all evaluations (mktime
tzgetname). Reported by Hamilton Slye.


# 1.116 27-Jan-2019 dholland

fix duplicated chunk from merge


# 1.115 27-Jan-2019 pgoyette

Merge the [pgoyette-compat] branch


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.114 01-Jan-2019 christos

Release 2018i - 2018-12-30 11:05:43 -0800

Briefly:
S��o Tom�� and Pr��ncipe switches from +01 to +00 on 2019-01-01.

Changes to future timestamps

Due to a change in government, S��o Tom�� and Pr��ncipe switches back
from +01 to +00 on 2019-01-01 at 02:00. (Thanks to Vadim
Nasardinov and Michael Deckers.)


Release 2018h - 2018-12-23 17:59:32 -0800

Briefly:
Qyzylorda, Kazakhstan moved from +06 to +05 on 2018-12-21.
New zone Asia/Qostanay because Qostanay, Kazakhstan didn't move.
Metlakatla, Alaska observes PST this winter only.
Guess Morocco will continue to adjust clocks around Ramadan.
Add predictions for Iran from 2038 through 2090.

Changes to future timestamps

Guess that Morocco will continue to fall back just before and
spring forward just after Ramadan, the practice since 2012.
(Thanks to Maamar Abdelkader.) This means Morocco will observe
negative DST during Ramadan in main and vanguard formats, and in
rearguard format it stays in the +00 timezone and observes
ordinary DST in all months other than Ramadan. As before, extend
this guesswork to the year 2037. As a consequence, Morocco is
scheduled to observe three DST transitions in some Gregorian years
(e.g., 2033) due to the mismatch between the Gregorian and Islamic
calendars.

The table of exact transitions for Iranian DST has been extended.
It formerly cut off before the year 2038 in a nod to 32-bit time_t.
It now cuts off before 2091 as there is doubt about how the Persian
calendar will treat 2091. This change predicts DST transitions in
2038-9, 2042-3, and 2046-7 to occur one day later than previously
predicted. As before, post-cutoff transitions are approximated.

Changes to past and future timestamps

Qyzylorda (aka Kyzylorda) oblast in Kazakhstan moved from +06 to
+05 on 2018-12-21. This is a zone split as Qostanay (aka
Kostanay) did not switch, so create a zone Asia/Qostanay.

Metlakatla moved from Alaska to Pacific standard time on 2018-11-04.
It did not change clocks that day and remains on -08 this winter.
(Thanks to Ryan Stanley.) It will revert to the usual Alaska
rules next spring, so this change affects only timestamps
from 2018-11-04 through 2019-03-10.

Change to past timestamps

Kwajalein's 1993-08-20 transition from -12 to +12 was at 24:00,
not 00:00. I transcribed the time incorrectly from Shanks.
(Thanks to Phake Nick.)

Nauru's 1979 transition was on 02-10 at 02:00, not 05-01 at 00:00.
(Thanks to Phake Nick.)

Guam observed DST irregularly from 1959 through 1977.
(Thanks to Phake Nick.)

Hong Kong observed DST in 1941 starting 06-15 (not 04-01), then on
10-01 changed standard time to +08:30 (not +08). Its transition
back to +08 after WWII was on 1945-09-15, not the previous day.
Its 1904-10-30 change took effect at 01:00 +08 (not 00:00 LMT).
(Thanks to Phake Nick, Steve Allen, and Joseph Myers.) Also,
its 1952 fallback was on 11-02 (not 10-25).

This release contains many changes to timestamps before 1946 due
to Japanese possession or occupation of Pacific/Chuuk,
Pacific/Guam, Pacific/Kosrae, Pacific/Kwajalein, Pacific/Majuro,
Pacific/Nauru, Pacific/Palau, and Pacific/Pohnpei.
(Thanks to Phake Nick.)

Assume that the Spanish East Indies was like the Philippines and
observed American time until the end of 1844. This affects
Pacific/Chuuk, Pacific/Kosrae, Pacific/Palau, and Pacific/Pohnpei.

Changes to past tm_isdst flags

For the recent Morocco change, the tm_isdst flag should be 1 from
2018-10-27 00:00 to 2018-10-28 03:00. (Thanks to Michael Deckers.)
Give a URL to the official decree. (Thanks to Matt Johnson.)


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.113 19-Oct-2018 christos

Update to 2018f:

Changes to code

zic now always generates TZif files where time type 0 is used for
timestamps before the first transition. This simplifies the
reading of TZif files and should not affect behavior of existing
TZif readers because the same set of time types is used; only
their internal indexes may have changed. This affects only the
legacy zones EST5EDT, CST6CDT, MST7MDT, PST8PDT, CET, MET, and
EET, which previously used nonzero types for these timestamps.

Because of the type 0 change, zic no longer outputs a dummy
transition at time -2**59 (before the Big Bang), as clients should
no longer need this to handle historical timestamps correctly.
This reverts a change introduced in 2013d and shrinks most TZif
files by a few bytes.

zic now supports negative time-of-day in Rule and Leap lines, e.g.,
"Rule X min max - Apr lastSun -6:00 1:00 -" means the transition
occurs at 18:00 on the Saturday before the last Sunday in April.
This behavior was documented in 2018a but the code did not
entirely match the documentation.

localtime.c no longer requires at least one time type in TZif
files that lack transitions or have a POSIX-style TZ string. This
future-proofs the code against possible future extensions to the
format that would allow TZif files with POSIX-style TZ strings and
without transitions or time types.

A read-access subscript error in localtime.c has been fixed.
It could occur only in TZif files with timecnt == 0, something that
does not happen in practice now but could happen in future versions.

localtime.c no longer ignores TZif POSIX-style TZ strings that
specify only standard time. Instead, these TZ strings now
override the default time type for timestamps after the last
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.

leapseconds.awk now outputs "#updated" and "#expires" comments,
and supports leap seconds at the ends of months other than June
and December. (Inspired by suggestions from Chris Woodbury.)

Changes to documentation

New restrictions: A Rule name must start with a character that
is neither an ASCII digit nor "-" nor "+", and an unquoted name
should not use characters in the set "!$%&'()*,/:;<=>?@[\]^`{|}~".
The latter restriction makes room for future extensions (a
possibility noted by Tom Lane).

tzfile.5 now documents what time types apply before the first and
after the last transition, if any.

Documentation now uses the spelling "timezone" for a TZ setting
that determines timestamp history, and "time zone" for a
geographic region currently sharing the same standard time.

The name "TZif" is now used for the tz binary data format.

tz-link.htm now mentions the A0 TimeZone Migration utilities.
(Thanks to Aldrin Martoq for the link.)


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.112 04-May-2018 christos

Merge 2018e

Changes to code

zic now accepts subsecond precision in expressions like
00:19:32.13, which is approximately the legal time of the
Netherlands from 1835 to 1937. However, because it is
questionable whether the few recorded uses of non-integer offsets
had subsecond precision in practice, there are no plans for tzdata
to use this feature. (Thanks to Steve Allen for pointing out
the limitations of historical data in this area.)

The code is a bit more portable to MS-Windows. Installers can
compile with -DRESERVE_STD_EXT_IDS on MS-Windows platforms that
reserve identifiers like 'localtime'. (Thanks to Manuela
Friedrich).

Changes to documentation and commentary

theory.html now outlines tzdb's extensions to POSIX's model for
civil time, and has a section "POSIX features no longer needed"
that lists POSIX API components that are now vestigial.
(From suggestions by Steve Summit.) It also better distinguishes
time zones from tz regions. (From a suggestion by Guy Harris.)

Commentary is now more consistent about using the phrase "daylight
saving time", to match the C name tm_isdst. Daylight saving time
need not occur in summer, and need not have a positive offset from
standard time.

Commentary about historical transitions in Uruguay has been expanded
with links to many relevant legal documents.
(Thanks to Tim Parenti.)

Commentary now uses some non-ASCII characters with Unicode value
less than U+0100, as they can be useful and should work even with
older editors such as XEmacs.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.111 25-Jan-2018 christos

branches: 1.111.2;
Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.111 25-Jan-2018 christos

Merge tzcode2018c [ changelog with changes to tzdata sections removed ]

Release 2018c - 2018-01-22 23:00:44 -0800

Changes to build procedure

The build procedure now works around mawk 1.3.3's lack of support
for character class expressions. (Problem reported by Ohyama.)


Release 2018b - 2018-01-17 23:24:48 -0800

Changes to build procedure

The distribution now contains the file 'pacificnew' again.
This file was inadvertantly omitted in the 2018a distribution.
(Problem reported by Matias Fonzo.)


Release 2018a - 2018-01-12 22:29:21 -0800

Changes to build procedure

The default installation locations have been changed to mostly
match Debian circa 2017, instead of being designed as an add-on to
4.3BSD circa 1986. This affects the Makefile macros TOPDIR,
TZDIR, MANDIR, and LIBDIR. New Makefile macros TZDEFAULT, USRDIR,
USRSHAREDIR, BINDIR, ZDUMPDIR, and ZICDIR let installers tailor
locations more precisely. (This responds to suggestions from
Brian Inglis and from Steve Summit.)

The default installation procedure no longer creates the
backward-compatibility link US/Pacific-New, which causes
confusion during user setup (e.g., see Debian bug 815200).
Use 'make BACKWARD="backward pacificnew"' to create the link
anyway, for now. Eventually we plan to remove the link entirely.

tzdata.zi now contains a version-number comment.
(Suggested by Tom Lane.)

The Makefile now quotes values like BACKWARD more carefully when
passing them to the shell. (Problem reported by Zefram.)

Builders no longer need to specify -DHAVE_SNPRINTF on platforms
that have snprintf and use pre-C99 compilers. (Problem reported
by Jon Skeet.)

Changes to code

zic has a new option -t FILE that specifies the location of the
file that determines local time when TZ is unset. The default for
this location can be configured via the new TZDEFAULT makefile
macro, which defaults to /etc/localtime.

Diagnostics and commentary now distinguish UT from UTC more
carefully; see theory.html for more information about UT vs UTC.

zic has been ported to GCC 8's -Wstringop-truncation option.
(Problem reported by Martin Sebor.)

Changes to documentation and commentary

The zic man page now documents the longstanding behavior that
times and years can be out of the usual range, with negative times
counting backwards from midnight and with year 0 preceding year 1.
(Problem reported by Michael Deckers.)

The theory.html file now mentions the POSIX limit of six chars
per abbreviation, and lists alphabetic abbreviations used.

The files tz-art.htm and tz-link.htm have been renamed to
tz-art.html and tz-link.html, respectively, for consistency with
other file names and to simplify web server configuration.


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.110 27-Oct-2017 kre

Replace a line that somehow got lost in the import from tzcode2017c


# 1.109 24-Oct-2017 christos

Welcome to 2017c:

zic and the reference runtime now reject multiple leap seconds
within 28 days of each other, or leap seconds before the Epoch.
As a result, support for double leap seconds, which was
obsolescent and undocumented, has been removed. Double leap
seconds were an error in the C89 standard; they have never existed
in civil timekeeping. (Thanks to Robert Elz and Bradley White for
noticing glitches in the code that uncovered this problem.)

zic now warns about use of the obsolescent and undocumented -y
option, and about use of the obsolescent TYPE field of Rule lines.

zic now allows unambiguous abbreviations like "Sa" and "Su" for
weekdays; formerly it rejected them due to a bug. Conversely, zic
no longer considers non-prefixes to be abbreviations; for example,
it no longer accepts "lF" as an abbreviation for "lastFriday".
Also, zic warns about the undocumented usage with a "last-"
prefix, e.g., "last-Fri".

Similarly, zic now accepts the unambiguous abbreviation "L" for
"Link" in ordinary context and for "Leap" in leap-second context.
Conversely, zic no longer accepts non-prefixes such as "La" as
abbreviations for words like "Leap".

zic no longer accepts leap second lines in ordinary input, or
ordinary lines in leap second input. Formerly, zic sometimes
warned about this undocumented usage and handled it incorrectly.

The new macro HAVE_TZNAME governs whether the tzname external
variable is exported, instead of USG_COMPAT. USG_COMPAT now
governs only the external variables "timezone" and "daylight".
This change is needed because the three variables are not in the
same category: although POSIX requires tzname, it specifies the
other two variables as optional. Also, USG_COMPAT is now 1 or 0:
if not defined, the code attempts to guess it from other macros.

localtime.c and difftime.c no longer require stdio.h, and .c files
other than zic.c no longer require sys/wait.h.

zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.)

Calculation of time_t extrema works around a bug in GCC 4.8.4
(Reported by Stan Shebs and Joseph Myers.)

zic.c no longer mistranslates formats of line numbers in non-English
locales. (Problem reported by Benno Schulenberg.)

Several minor changes have been made to the code to make it a
bit easier to port to MS-Windows and Solaris. (Thanks to Kees
Dekker for reporting the problems.)

Changes to documentation and commentary

The two new files 'theory.html' and 'calendars' contain the
contents of the removed file 'Theory'. The goal is to document
tzdb theory more accessibly.

The zic man page now documents abbreviation rules.

tz-link.htm now covers how to apply tzdata changes to clients.
(Thanks to Jorge F��bregas for the AIX link.) It also mentions MySQL.

The leap-seconds.list URL has been updated to something that is
more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.)


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


Revision tags: prg-localcount2-base2
# 1.108 10-May-2017 kre

Turns out that the previous fix is incorrect, we were not doing ++hit
to change the boolean hit from false to true, but to change it from 1 to 2
which in a sense should have been obvious from the context:
if (hit)
/* more tests */
++hit;
The real problem was that hit was (in the imported tzcode) incorrectly
changed from int to bool in a previous update.

Not that it matters, this code is never actually executed - it was there
to deal with the mythical double leapseconds, which simply never exist
(hit counted the number of leapseconds in an adjustment) and it will all
be gone in the next tzcode update.

For now, just turn hit back into an int, which should satisfy gcc 8,
I hope.


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

branches: 1.106.2;
merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

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

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

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

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

Changes to the 'zic' man page

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

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

Its examples are updated to match the latest data.

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

Changes to the 'Theory' file

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

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

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

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

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

It gives more reasons for the 1970 cutoff.

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

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

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

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

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


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.107 09-May-2017 maya

++bool to bool=true to appease GCC 8. NFC

ok riastradh


Revision tags: prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.106 11-Mar-2017 christos

merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

branches: 1.105.2;
tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

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

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

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


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

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

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

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

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

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

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

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

Changes affecting the zdump utility

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

Data changes affecting behavior of tzselect and similar programs

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

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

Changes affecting code internals

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

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

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

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

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

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

The links America/Shiprock and Antarctica/South_Pole have been
moved to the 'backward' file. This affects only nondefault builds
that omit 'backward'.

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

It now mentions that the binary file format may be extended in
future versions by appending data.

It now refers to the 'zdump' and 'zic' man pages.

Changes to the 'zic' man page

It lists conditions that elicit a warning with '-v'.

It says that the behavior is unspecified when duplicate names
are given, or if the source of one link is the target of another.

Its examples are updated to match the latest data.

The definition of white space has been clarified slightly.
(Thanks to Michael Deckers.)

Changes to the 'Theory' file

There is a new section about the accuracy of the tz database,
describing the many ways that errors can creep in, and
explaining why so many of the pre-1970 time stamps are wrong or
misleading (thanks to Steve Allen, Lester Caine, and Garrett
Wollman for discussions that contributed to this).

The 'Theory' file describes LMT better (this follows a
suggestion by Guy Harris).

It refers to the 2013 edition of POSIX rather than the 2004 edition.

It's mentioned that excluding 'backward' should not affect the
other data, and it suggests at least one zone.tab name per
inhabited country (thanks to Stephen Colebourne).

Some longstanding restrictions on names are documented, e.g.,
'America/New_York' precludes 'America/New_York/Bronx'.

It gives more reasons for the 1970 cutoff.

It now mentions which time_t variants are supported, such as
signed integer time_t. (Thanks to Paul Goyette for reporting
typos in an experimental version of this change.)

(Thanks to Philip Newton for correcting typos in these changes.)

Documentation and commentary is more careful to distinguish UT in
general from UTC in particular. (Thanks to Steve Allen.)

Add a better source for the Zurich 1894 transition.
(Thanks to Pierre-Yves Berger.)

Update shapefile citations in tz-link.htm. (Thanks to Guy Harris.)


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.106 11-Mar-2017 christos

merge 2017a


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.105 04-Nov-2016 christos

tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

branches: 1.81.2;
update from tzcode 2013e to tzcode2013i
i:
The compile-time flag NOSOLAR has been removed, as nowadays the
benefit of slightly shrinking runtime table size is outweighed by the
cost of disallowing potential future updates that exceed old limits.
h:
Fix localtime overflow bugs with 32-bit unsigned time_t.

zdump no longer assumes sscanf returns maximal values on overflow.
g:
'zic' now runs on platforms that lack both hard links and symlinks.
(Thanks to Theo Veenker for reporting the problem, for MinGW.)
Also, fix some bugs on platforms that lack hard links but have symlinks.

'zic -v' again warns that Asia/Tehran has no POSIX environment variable
to predict the far future, fixing a bug introduced in 2013e.
f:
The types of the global variables 'timezone' and 'altzone' (if present)
have been changed back to 'long'. This is required for 'timezone'
by POSIX, and for 'altzone' by common practice, e.g., Solaris 11.
These variables were originally 'long' in the tz code, but were
mistakenly changed to 'time_t' in 1987; nobody reported the
incompatibility until now. The difference matters on x32, where
'long' is 32 bits and 'time_t' is 64. (Thanks to Elliott Hughes.)


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

The 'zic' command now outputs a dummy transition when far-future
data can't be summarized using a TZ string, and uses a 402-year
window rather than a 400-year window. For the current data, this
affects only the Asia/Tehran file. It does not affect any of the
time stamps that this file represents, so zdump outputs the same
information as before. (Thanks to Andrew Main (Zefram).)

The 'date' command has a new '-r' option, which lets you specify
the integer time to display, a la FreeBSD.

The 'tzselect' command has two new options '-c' and '-n', which lets you
select a zone based on latitude and longitude.

The 'zic' command's '-v' option now warns about constructs that
require the new version-3 binary file format. (Thanks to Arthur
David Olson for the suggestion.)

Support for floating-point time_t has been removed.
It was always dicey, and POSIX no longer requires it.
(Thanks to Eric Blake for suggesting to the POSIX committee to
remove it, and thanks to Alan Barrett, Clive D.W. Feather, Andy
Heninger, Arthur David Olson, and Alois Treindl, for reporting
bugs and elucidating some of the corners of the old floating-point
implementation.)

The signatures of 'offtime', 'timeoff', and 'gtime' have been
changed back to the old practice of using 'long' to represent UT
offsets. This had been inadvertently and mistakenly changed to
'int_fast32_t'. (Thanks to Christos Zoulos.)

The code avoids undefined behavior on integer overflow in some
more places, including gmtime, localtime, mktime and zdump.

Changes affecting the zdump utility

zdump now outputs "UT" when referring to Universal Time, not "UTC".
"UTC" does not make sense for time stamps that predate the introduction
of UTC, whereas "UT", a more-generic term, does. (Thanks to Steve Allen
for clarifying UT vs UTC.)

Data changes affecting behavior of tzselect and similar programs

Country code BQ is now called the more-common name "Caribbean Netherlands"
rather than the more-official "Bonaire, St Eustatius & Saba".

Remove from zone.tab the names America/Montreal, America/Shiprock,
and Antarctica/South_Pole, as they are equivalent to existing
same-country-code zones for post-1970 time stamps. The data for
these names are unchanged, so the names continue to work as before.

Changes affecting code internals

zic -c now runs way faster on 64-bit hosts when given large numbers.

zic now uses vfprintf to avoid allocating and freeing some memory.

tzselect now computes the list of continents from the data,
rather than have it hard-coded.

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

The 'leapseconds' file is now generated automatically from a
new file 'leap-seconds.list', which is a copy of
<ftp://time.nist.gov/pub/leap-seconds.list>.
A new source file 'leapseconds.awk' implements this.
The goal is simplification of the future maintenance of 'leapseconds'.

When building the 'posix' or 'right' subdirectories, if the
subdirectory would be a copy of the default subdirectory, it is
now made a symbolic link if that is supported. This saves about
2 MB of file system space.

The links America/Shiprock and Antarctica/South_Pole have been
moved to the 'backward' file. This affects only nondefault builds
that omit 'backward'.

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

It now mentions that the binary file format may be extended in
future versions by appending data.

It now refers to the 'zdump' and 'zic' man pages.

Changes to the 'zic' man page

It lists conditions that elicit a warning with '-v'.

It says that the behavior is unspecified when duplicate names
are given, or if the source of one link is the target of another.

Its examples are updated to match the latest data.

The definition of white space has been clarified slightly.
(Thanks to Michael Deckers.)

Changes to the 'Theory' file

There is a new section about the accuracy of the tz database,
describing the many ways that errors can creep in, and
explaining why so many of the pre-1970 time stamps are wrong or
misleading (thanks to Steve Allen, Lester Caine, and Garrett
Wollman for discussions that contributed to this).

The 'Theory' file describes LMT better (this follows a
suggestion by Guy Harris).

It refers to the 2013 edition of POSIX rather than the 2004 edition.

It's mentioned that excluding 'backward' should not affect the
other data, and it suggests at least one zone.tab name per
inhabited country (thanks to Stephen Colebourne).

Some longstanding restrictions on names are documented, e.g.,
'America/New_York' precludes 'America/New_York/Bronx'.

It gives more reasons for the 1970 cutoff.

It now mentions which time_t variants are supported, such as
signed integer time_t. (Thanks to Paul Goyette for reporting
typos in an experimental version of this change.)

(Thanks to Philip Newton for correcting typos in these changes.)

Documentation and commentary is more careful to distinguish UT in
general from UTC in particular. (Thanks to Steve Allen.)

Add a better source for the Zurich 1894 transition.
(Thanks to Pierre-Yves Berger.)

Update shapefile citations in tz-link.htm. (Thanks to Guy Harris.)


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision


# 1.105 04-Nov-2016 christos

tzcode2016i


Revision tags: pgoyette-localcount-20161104
# 1.104 07-Oct-2016 christos

merge tzcode2016g


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.103 18-Mar-2016 ginsbach

branches: 1.103.2;
Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt. Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.


# 1.102 15-Mar-2016 christos

Sync with 2016b


# 1.101 20-Feb-2016 christos

PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7


# 1.100 29-Oct-2015 christos

another lint warning for compat.


# 1.99 29-Oct-2015 christos

Add tzgetgmtoff, delint compat


# 1.98 09-Oct-2015 christos

Release 2015g - 2015-10-01 00:39:51 -0700

Changes affecting code

localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Changes affecting documentation

The tzfile man page now documents that transition times denote the
starts (not the ends) of the corresponding time periods.
(Ambiguity reported by Bill Seymour.)


# 1.97 18-Aug-2015 riz

Remove second 'const' declaration, to hopefully fix clang builds.


# 1.96 13-Aug-2015 christos

merge 2015f


# 1.95 21-Jun-2015 christos

merge tzcode2015e:

Changes affecting code

When displaying data, tzselect converts it to the current locale's
encoding if the iconv command works. (Problem reported by random832.)

tzselect no longer mishandles Dominica, fixing a bug introduced
in Release 2014f. (Problem reported by Owen Leibman.)

zic -l no longer fails when compiled with -DTZDEFAULT=\"/etc/localtime\".
This fixes a bug introduced in Release 2014f.
(Problem reported by Leonardo Chiquitto.)


# 1.94 24-Mar-2015 christos

merge 2015b


# 1.93 31-Jan-2015 christos

merge tzcode2015a:

tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.


# 1.92 11-Nov-2014 christos

localtime did not set tm->tm_zone properly making pkgsrc emacs core-dump.
Thanks to Masanori Kanaoka.


# 1.91 23-Oct-2014 christos

merge 2014i


# 1.90 16-Oct-2014 christos

- don't leak errno in mktime()
- when we load a new timezone, don't change anything unless the load succeeded.


# 1.89 15-Oct-2014 christos

PR/49284: Andreas Gustafsson: sysinst segfaults when configuring network
manually. When tzload() fails called from zoneinit(), when trying to set the
local timezone for the first time in tzsetlcl(), we end up with a lclptr
that contains garbage, so settzname() core-dumps.

Thanks Andreas for the analysis!


# 1.88 14-Oct-2014 christos

improve error checking (setting errno)


# 1.87 07-Oct-2014 christos

Sync with tzcode2014h


# 1.86 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


# 1.85 16-Aug-2014 christos

Reduce diffs with upstream by automatically defining INITIALIZE as it was
intended.


# 1.84 15-Aug-2014 martin

Intialize dstname - the invariant combination with dstlen is too complex
for gcc to follow.


# 1.83 15-Aug-2014 christos

merge tzcode2014f via patch


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.82 13-May-2014 christos

branches: 1.82.2;
Welcome to 2014c
Changes affecting code

zic now generates transitions for minimum time values, eliminating
guesswork when handling low-valued time stamps. (Thanks to Arthur
David Olson.)

Port to Cygwin sans glibc. (Thanks to Arthur David Olson.)

Changes affecting commentary and documentation

Remove now-confusing comment about Jordan. (Thanks to Oleksii
Nochovnyi.)


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.81 26-Dec-2013 christos

branches: 1.81.2;
update from tzcode 2013e to tzcode2013i
i:
The compile-time flag NOSOLAR has been removed, as nowadays the
benefit of slightly shrinking runtime table size is outweighed by the
cost of disallowing potential future updates that exceed old limits.
h:
Fix localtime overflow bugs with 32-bit unsigned time_t.

zdump no longer assumes sscanf returns maximal values on overflow.
g:
'zic' now runs on platforms that lack both hard links and symlinks.
(Thanks to Theo Veenker for reporting the problem, for MinGW.)
Also, fix some bugs on platforms that lack hard links but have symlinks.

'zic -v' again warns that Asia/Tehran has no POSIX environment variable
to predict the far future, fixing a bug introduced in 2013e.
f:
The types of the global variables 'timezone' and 'altzone' (if present)
have been changed back to 'long'. This is required for 'timezone'
by POSIX, and for 'altzone' by common practice, e.g., Solaris 11.
These variables were originally 'long' in the tz code, but were
mistakenly changed to 'time_t' in 1987; nobody reported the
incompatibility until now. The difference matters on x32, where
'long' is 32 bits and 'time_t' is 64. (Thanks to Elliott Hughes.)


# 1.80 13-Dec-2013 christos

time_t_{min,max} are only used in localtime.c


# 1.79 13-Dec-2013 christos

add a cast for sparc64 where int_fast32_t is long (should it be?), and
time_t is int32_t (for compat)


# 1.78 20-Sep-2013 christos

Welcome to tzcode 2013e:

Changes affecting API

The 'zic' command now outputs a dummy transition when far-future
data can't be summarized using a TZ string, and uses a 402-year
window rather than a 400-year window. For the current data, this
affects only the Asia/Tehran file. It does not affect any of the
time stamps that this file represents, so zdump outputs the same
information as before. (Thanks to Andrew Main (Zefram).)

The 'date' command has a new '-r' option, which lets you specify
the integer time to display, a la FreeBSD.

The 'tzselect' command has two new options '-c' and '-n', which lets you
select a zone based on latitude and longitude.

The 'zic' command's '-v' option now warns about constructs that
require the new version-3 binary file format. (Thanks to Arthur
David Olson for the suggestion.)

Support for floating-point time_t has been removed.
It was always dicey, and POSIX no longer requires it.
(Thanks to Eric Blake for suggesting to the POSIX committee to
remove it, and thanks to Alan Barrett, Clive D.W. Feather, Andy
Heninger, Arthur David Olson, and Alois Treindl, for reporting
bugs and elucidating some of the corners of the old floating-point
implementation.)

The signatures of 'offtime', 'timeoff', and 'gtime' have been
changed back to the old practice of using 'long' to represent UT
offsets. This had been inadvertently and mistakenly changed to
'int_fast32_t'. (Thanks to Christos Zoulos.)

The code avoids undefined behavior on integer overflow in some
more places, including gmtime, localtime, mktime and zdump.

Changes affecting the zdump utility

zdump now outputs "UT" when referring to Universal Time, not "UTC".
"UTC" does not make sense for time stamps that predate the introduction
of UTC, whereas "UT", a more-generic term, does. (Thanks to Steve Allen
for clarifying UT vs UTC.)

Data changes affecting behavior of tzselect and similar programs

Country code BQ is now called the more-common name "Caribbean Netherlands"
rather than the more-official "Bonaire, St Eustatius & Saba".

Remove from zone.tab the names America/Montreal, America/Shiprock,
and Antarctica/South_Pole, as they are equivalent to existing
same-country-code zones for post-1970 time stamps. The data for
these names are unchanged, so the names continue to work as before.

Changes affecting code internals

zic -c now runs way faster on 64-bit hosts when given large numbers.

zic now uses vfprintf to avoid allocating and freeing some memory.

tzselect now computes the list of continents from the data,
rather than have it hard-coded.

Minor changes pacify GCC 4.7.3 and GCC 4.8.1.

Changes affecting the build procedure

The 'leapseconds' file is now generated automatically from a
new file 'leap-seconds.list', which is a copy of
<ftp://time.nist.gov/pub/leap-seconds.list>.
A new source file 'leapseconds.awk' implements this.
The goal is simplification of the future maintenance of 'leapseconds'.

When building the 'posix' or 'right' subdirectories, if the
subdirectory would be a copy of the default subdirectory, it is
now made a symbolic link if that is supported. This saves about
2 MB of file system space.

The links America/Shiprock and Antarctica/South_Pole have been
moved to the 'backward' file. This affects only nondefault builds
that omit 'backward'.

Changes affecting documentation and commentary

Changes to the 'tzfile' man page

It now mentions that the binary file format may be extended in
future versions by appending data.

It now refers to the 'zdump' and 'zic' man pages.

Changes to the 'zic' man page

It lists conditions that elicit a warning with '-v'.

It says that the behavior is unspecified when duplicate names
are given, or if the source of one link is the target of another.

Its examples are updated to match the latest data.

The definition of white space has been clarified slightly.
(Thanks to Michael Deckers.)

Changes to the 'Theory' file

There is a new section about the accuracy of the tz database,
describing the many ways that errors can creep in, and
explaining why so many of the pre-1970 time stamps are wrong or
misleading (thanks to Steve Allen, Lester Caine, and Garrett
Wollman for discussions that contributed to this).

The 'Theory' file describes LMT better (this follows a
suggestion by Guy Harris).

It refers to the 2013 edition of POSIX rather than the 2004 edition.

It's mentioned that excluding 'backward' should not affect the
other data, and it suggests at least one zone.tab name per
inhabited country (thanks to Stephen Colebourne).

Some longstanding restrictions on names are documented, e.g.,
'America/New_York' precludes 'America/New_York/Bronx'.

It gives more reasons for the 1970 cutoff.

It now mentions which time_t variants are supported, such as
signed integer time_t. (Thanks to Paul Goyette for reporting
typos in an experimental version of this change.)

(Thanks to Philip Newton for correcting typos in these changes.)

Documentation and commentary is more careful to distinguish UT in
general from UTC in particular. (Thanks to Steve Allen.)

Add a better source for the Zurich 1894 transition.
(Thanks to Pierre-Yves Berger.)

Update shapefile citations in tz-link.htm. (Thanks to Guy Harris.)


# 1.77 30-Jul-2013 joerg

Don't depend on implicit rounding from non-integral float constant.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.76 22-Jul-2013 msaitoh

Both increment_overflow() and normalize_overflow() have two different
declarations. One must be *32(). Fixes compile error observed on sparc64.


# 1.75 17-Jul-2013 christos

remove "register" in new code
fix backwards check for overflow


# 1.74 17-Jul-2013 christos

welcome to 2013d


Revision tags: riastradh-drm2-base agc-symver-base
# 1.73 02-Mar-2013 christos

branches: 1.73.4;
update to tzcode2013a


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.72 28-Oct-2012 christos

add a cast to appease the compat build.


# 1.71 28-Oct-2012 christos

welcome to tzcode2012h via patch.


# 1.70 26-Oct-2012 christos

stronger lint foo


# 1.69 26-Oct-2012 christos

- whitespace
- s/consttmp/const tmp/
- sync comments
- don't save errno where it is not needed
- consistent lint comments


# 1.68 24-Oct-2012 christos

apply 2012g via patch


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.67 20-Mar-2012 matt

branches: 1.67.2;
Remove use of __P
Switch to using C89 definitions.


# 1.66 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base
# 1.65 07-Jan-2012 martin

Do not force errno to EOVERFLOW when returning -1 from mktime or friends.
First, there are legitimate cases where we want to return -1 and errno == 0,
second, all paths go through time1() and/or time2sub() which explicitly
take care to set errno in cases of real overflows.
Should fix atf test failure on various ports in
lib/libc/time/t_mktime:timegm_epoch.


Revision tags: yamt-pagecache-base3
# 1.64 08-Nov-2011 christos

Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.


Revision tags: yamt-pagecache-base2
# 1.63 07-Nov-2011 christos

no need to adjust the off, hi is already at the right time.


Revision tags: yamt-pagecache-base
# 1.62 28-Oct-2011 christos

branches: 1.62.2;
Only advance the time if we are skipping the gap.


# 1.61 28-Oct-2011 christos

prevent underflow from giving us a false positive test in the first iteration.


# 1.60 27-Oct-2011 christos

Change mktime*(3) so that it does not always return EOVERFLOW when it cannot
perform the conversion, but returns EINVAL when the time requested would fall
in the DST gap, or is not representable in the timezone requested, and document
this.


# 1.59 16-Oct-2011 christos

Add code (not enabled) that allows mktime() to return a value for times
in the DST gap when tm_isdst == -1, like glibc does. Document both behaviors.


# 1.58 04-Sep-2011 christos

bring in the 2011i changes.


# 1.57 16-Jun-2011 christos

don't modify tzname unless we are the non-reentrant version.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase
# 1.56 21-Feb-2011 christos

branches: 1.56.2;
remove duplicate weak aliases


Revision tags: bouyer-quota2-base
# 1.55 13-Feb-2011 christos

Don't forget to set errno. Pointed out by yamt.


# 1.54 15-Jan-2011 christos

branches: 1.54.2;
Fix reversed oveflow check.


# 1.53 15-Jan-2011 martin

Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.


# 1.52 14-Jan-2011 christos

don't depend on integer oveflow wrapping to detect it. From Paul Eggert in
the tz mailing list.


# 1.51 06-Jan-2011 christos

Since localsub and gmtsub are called recursively to search for the local
time, setting EOVERFLOW at the inmost level will unfortunately persist,
even if later calls to those functions succeed. Move the EOVERFLOW setting
to the top level calls.


Revision tags: matt-mips64-premerge-20101231
# 1.50 17-Dec-2010 christos

PR/44248: Antti Kantee: Fix multi-threaded localtime hang.


# 1.49 16-Dec-2010 christos

Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.


# 1.48 23-Mar-2010 drochner

remove some stray __weak_aliases, where the target functions were
__RENAMEd due to the time_t/dev_t type changes, which caused bogus
references to compat functions
now a libc built with BUILDCOLD is usable


# 1.47 17-Feb-2010 christos

Fix a bug reported by Gene, and debugged by Robert Elz. fsck_ffs can coredump
if the timezone file fails to load, due to late initialization of sp->goahead
to false in tzload, causing localsub to return NULL in the "cannot happen"
case. The fix is belt and suspenders:
- initialize sp->goback and sp->goahead very early in tzload
- replace all malloc calls with callocs, and remove the bogus
casts (it is not the 70's anymore!)


# 1.46 02-Feb-2010 christos

According to TOG:
- asctime{,_r}, ctime{,_r} may return NULL; document that, and avoid coredumps.
- gmtime{,_r}, localtime{,_r} may return NULL and set EOVERFLOW, document and
set errno.
- when mktime returns (time_t)-1, make it set EOVERFLOW and document it.

XXX: Should be pulled up to 5.x


# 1.45 31-Dec-2009 mlelstv

Import tzcode2009k.
- now understands 64bit time_t and 64bit data in timezone files.
- localtime(), gmtime(), asctime() and ctime() may now fail with
a NULL result if time_t cannot be represented by struct tm.


Revision tags: matt-premerge-20091211
# 1.44 24-Oct-2009 mlelstv

With 64bit time_t years can be negative and lapyear computation
requires rounding down. This avoids an infinite loop in localtime().


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.43 18-Jan-2009 drochner

Make mktime(3) work with 64-bit time_t.
The problem is that the tm_year field of "struct tm" is just an "int"
(per POSIX), and thus time_t values > 2^31*60*60*24*365 cannot
be converted. This made mktime(3) fail even if no such large time values
were passed in by user code because the algorithm does a binary search
over the time_t range which fails if a probe value cannot be converted.
To fix this, limit the time_t range to be scanned to 55 bits (which
is a bit on the safe side, but still good until y570855533).
This is more a stopgap fix, the overflow should be checked for
at other places as well (eg localtime(3)), and there are some more
limitations in timezone parsing code.


# 1.42 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.41 27-Aug-2008 christos

branches: 1.41.6;
malloc(3) and getenv(3) affect errno; make sure we save and restore it
Reported by Andy Shevchenko


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.40 25-May-2008 dholland

Fix handling of legacy global variable timezone outputs. PR misc/22221.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.39 22-Mar-2006 christos

branches: 1.39.18; 1.39.20;
Remove a variable that became set-and-not-used after the dead code removal.


# 1.38 22-Mar-2006 christos

Coverity CID 578: remove dead code


# 1.37 16-Jul-2005 christos

Fix linted comments and use __UNCONST.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.36 16-Nov-2004 christos

PR/28324: Takayoshi Kochi: localtime_r(3) returns GMT
Add missing tzset_unlocked(); as suggested.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.35 20-Dec-2003 kleink

branches: 1.35.4;
Merge tzcode2003e.


# 1.34 29-Oct-2003 kleink

Merge tzcode2003d.


# 1.33 18-Jan-2003 christos

s/_REENT/_REENTRANT/


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.32 17-Nov-2002 itojun

use strlcpy where it is more appropriate.


# 1.31 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.30 16-Apr-2002 groo

botched strncpy -> strlcpy
from xs@kittenz.org


# 1.29 29-Jan-2002 kleink

Merge tzcode2002b.


# 1.28 04-Nov-2001 lukem

fix WARNS=2 (-Wshadow) warnings


# 1.27 27-Apr-2001 atatat

If the TZ environment variable was set to the empty string, a call to
ctime() would get a bus error (or a segmentation fault). Setting these
variables eliminates that problem.

Fixes pr lib/12750.


# 1.26 31-Mar-2001 kleink

Oops, missed type change in previous.


# 1.25 31-Mar-2001 kleink

Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.


# 1.24 13-Sep-2000 msaitoh

branches: 1.24.2;
check LIBC_SCCS


Revision tags: netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.23 22-Jan-2000 mycroft

branches: 1.23.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.22 10-Nov-1999 kleink

Merge tzcode1999h.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 15-Nov-1998 christos

branches: 1.21.6;
delint


# 1.20 16-Oct-1998 kleink

Need an internal name for tzname.


# 1.19 13-Sep-1998 kleink

Protect local time state and GMT data initialization with a readers/writer lock
and a mutex, respectively.


# 1.18 10-Sep-1998 kleink

Merge tzcode1998f.


# 1.17 28-Jul-1998 mycroft

Slight adjustment needed for previous.


# 1.16 27-Jul-1998 mycroft

Make these compile without __AUDIT__.


# 1.15 26-Jul-1998 mycroft

const poisoning.


# 1.14 22-Jan-1998 jtc

sync with tzcode1998a


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.13 05-Sep-1997 jtc

sync with tzcode1997g


# 1.12 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.11 13-Jul-1997 christos

Fix RCSID's


# 1.10 18-Jun-1997 jtc

Sync with tzcode1997e


# 1.9 22-Apr-1997 mrg

note possible security concerns.


# 1.8 23-Jan-1997 mrg

- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.


# 1.7 10-Sep-1996 jtc

branches: 1.7.2;
sync with tzcode96l


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.6 20-Jan-1996 jtc

sync with tzcode96c


# 1.5 08-Jan-1996 jtc

sync with tzcode96a


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.4 16-Mar-1995 jtc

Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char
detzcode() extracts requiring sign extention (this is needed for
machines with 64 bit longs).

Our implementation is a bit more efficent, but requires a new macro,
SIGN_EXTEND_CHAR(), and a conditional to set it appropriately).

One minor enhancement for machines without ANSI compilers that have 32
bit longs would be to define SIGN_EXTEND_CHAR() to be the identity
macro.


# 1.3 10-Mar-1995 jtc

branches: 1.3.2;
A slightly modified version of Chris' patch so that detzcode will sign
extend properly on machines with 64 bit longs.
This patch has been submitted to the tz mailing list.


# 1.2 09-Mar-1995 jtc

Add NetBSD Id's.


# 1.1 09-Mar-1995 jtc

branches: 1.1.1;
Initial revision