summaryrefslogtreecommitdiff
path: root/lib/libc/time
AgeCommit message (Collapse)Author
2023-01-17put attributes first for c23 compliance.christos
2023-01-15Apply 9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f for C23 attribute compliance.christos
Requested by Jan-Benedict Glaw.
2022-12-13Handle the case the code originally intended to handle; systems where:christos
SIZE_MAX < PTRDIFF_MAX
2022-12-11Merge in 2022g:christos
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.
2022-12-04lib: Mark up error names in man pages with .Eruwe
2022-11-17Simply set HAVE_GETRANDOM to false on __APPLE__.jakllsch
Addresses PR 57083.
2022-11-16PR/57083: Jiaxun Yang: Fix build on MacOS/X which has <sys/random.h> but nochristos
getrandom(3).
2022-11-02Cleaner to use if/then/else rather than a ton of casts in the ternary operator.christos
2022-10-29Update to tzcode2022fchristos
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.
2022-10-26rephrase / clarify explanation of struct tm member normalizationjschauma
2022-10-25Fix a merge or conversion problem (probably) - a .SH BUGSkre
(meaningless macro in mdoc) followed by the first line of the real BUGS section somehow ended up inserted after the first word of the STANDARDS section. Delete the noise.
2022-10-24strptime(3): make the fact that %z is an extension more prominentuwe
Mention it near the format itself, not on the next screen (with an awkward indentation too).
2022-10-21ctime(3): fix unbalanced paren introduced in 1.40uwe
2022-10-21ctime(3): add missing leading slash in a pathnameuwe
2022-10-21escape mathematical minus so it doesn't get rendered as a dashjschauma
2022-10-21Note normalizing behavior of mktime(3) using language from FreeBSD.jschauma
2022-10-15update to 2022e; no real changeschristos
2022-08-24add missing text.christos
2022-08-23Fix argument namechristos
2022-08-16Welcome to tzcode-2022cchristos
Work around a bug in onetrueawk that broke commands like 'make traditional_tarballs' on FreeBSD, macOS, etc. (Problem reported by Deborah Goldsmith.) Add code to tzselect that uses experimental structured comments in zone1970.tab to clarify whether Zones like Africa/Abidjan and Europe/Istanbul cross continent or ocean boundaries. (Inspired by a problem reported by Peter Krefting.) Fix bug with 'zic -d /a/b/c' when /a is unwritable but the directory /a/b already exists. Remove zoneinfo2tdf.pl, as it was unused and triggered false malware alarms on some email servers.
2022-08-16Welcome to 2022b:christos
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.
2022-03-25localtime.c: fix theoretical syntax errorrillig
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.
2022-03-25localtime.c: reduce unnecessary diff to upstreamrillig
No binary change.
2022-03-25localtime.c: take indentation style from upstreamrillig
This reduces the diff to upstream. No binary change.
2022-03-25localtime.c: add back storage class 'register'rillig
This reduces the differences to the upstream code. No binary change.
2022-03-24put back the 2022a changes and fix the misplaced brace.christos
2022-03-23revert changes from 2022a for now until I figure out what's wrong.christos
2022-03-22welcome to tzcode-2022achristos
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.
2022-01-01zero out the tzh structure to fix reproducibile builds.christos
2021-12-05PR/56538: coypu: For compat ctime and friends (when time_t was 32 bits)christos
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.
2021-10-27fix problem with uninitialized variable on malformed 32 bit time.christos
2021-10-22Fix build failureryoon
* Fix merge mistake. * Cast to int for strict comparison like before.
2021-10-22Change to code and documentation from 2021a -> 2021echristos
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/>.
2021-09-28Remove duplicate tm_isdst. Fixes PR misc/56419 for HEAD.kim
2021-03-01Merge tzcode-2021achristos
- No comments in the changelog about the code changes.
2020-10-17update to 2020cchristos
2020-10-09Merge tzcode2020b (except we keep tzsetwall(3) for now for compatibility,christos
and we were "slim" already) Support for zic's long-obsolete '-y YEARISTYPE' option has been removed and, with it, so has support for the TYPE field in Rule lines, which is now reserved for compatibility with earlier zic. These features were previously deprecated in release 2015f. (Thanks to Tim Parenti.) zic now defaults to '-b slim' instead of to '-b fat'. zic's new '-l -' and '-p -' options uninstall any existing localtime and posixrules files, respectively. The undocumented and ineffective tzsetwall function has been removed.
2020-09-21Correct range for ISO week conversionginsbach
The %V conversion range for strptime(3) should match the strftime(3) conversion range. A valid ISO week is 1-53.
2020-05-25Bring in 2020achristos
2019-09-02start documenting historysevan
2019-07-03Sync with 2019b:christos
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.
2019-04-20Remove 'No' macros with no effect.wiz
Add width to table. Fix en-dashes.
2019-04-18Note restrictions on return values from tzgetname() and tzgmtoff()pgoyette
2019-04-17Pick up the latest matching (most recent) entry instead of the first one.christos
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.
2019-04-08The typecnt refers the to ttis array and the timecnt refers to the type array.christos
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.
2019-04-07don't print ???, requested by kre@christos
2019-04-07only need to initialize the first type.christos
2019-04-07Don't try to print NULL if we can't get a timezone name. First we try dst,christos
then we try the non-dst name and finally we just print ??? if that did not work. This is not needed to handle the "TZ= date" case which was crashing before because the default timezone was not consistently initialized, but should handle any timezone now.
2019-04-07Initialize the default timezone a bit more so that tzgetname(3) works.christos
2019-04-05- Padding support from FreeBSD (GNU extensions)christos
- add '+' for the c-locale only.