head 1.23; access; symbols netbsd-11-0-RC5:1.21 netbsd-11-0-RC4:1.21 netbsd-11-0-RC3:1.21 netbsd-11-0-RC2:1.21 netbsd-11-0-RC1:1.21 perseant-exfatfs-base-20250801:1.21 netbsd-11:1.21.0.2 netbsd-11-base:1.21 netbsd-10-1-RELEASE:1.17 perseant-exfatfs-base-20240630:1.19 perseant-exfatfs:1.19.0.2 perseant-exfatfs-base:1.19 netbsd-9-4-RELEASE:1.8 netbsd-10-0-RELEASE:1.17 netbsd-10-0-RC6:1.17 netbsd-10-0-RC5:1.17 netbsd-10-0-RC4:1.17 netbsd-10-0-RC3:1.17 netbsd-10-0-RC2:1.17 netbsd-10-0-RC1:1.17 netbsd-10:1.17.0.2 netbsd-10-base:1.17 netbsd-9-3-RELEASE:1.8 cjep_sun2x-base1:1.11 cjep_sun2x:1.11.0.4 cjep_sun2x-base:1.11 cjep_staticlib_x-base1:1.11 netbsd-9-2-RELEASE:1.8 cjep_staticlib_x:1.11.0.2 cjep_staticlib_x-base:1.11 netbsd-9-1-RELEASE:1.8 phil-wifi-20200421:1.8 phil-wifi-20200411:1.8 is-mlppp:1.8.0.4 is-mlppp-base:1.8 phil-wifi-20200406:1.8 netbsd-9-0-RELEASE:1.8 netbsd-9-0-RC2:1.8 netbsd-9-0-RC1:1.8 phil-wifi-20191119:1.8 netbsd-9:1.8.0.2 netbsd-9-base:1.8 phil-wifi-20190609:1.7 pgoyette-compat-merge-20190127:1.2.2.4 pgoyette-compat-20190127:1.6 pgoyette-compat-20190118:1.6 pgoyette-compat-1226:1.5 pgoyette-compat-1126:1.5 pgoyette-compat-1020:1.4 pgoyette-compat-0930:1.3 pgoyette-compat-0906:1.3 pgoyette-compat-0728:1.3 phil-wifi:1.3.0.2 phil-wifi-base:1.3 pgoyette-compat-0625:1.3 pgoyette-compat-0521:1.3 pgoyette-compat-0502:1.2 pgoyette-compat-0422:1.2 pgoyette-compat-0415:1.2 pgoyette-compat-0407:1.2 pgoyette-compat-0330:1.2 pgoyette-compat-0322:1.2 pgoyette-compat-0315:1.2 pgoyette-compat:1.2.0.2 pgoyette-compat-base:1.2; locks; strict; comment @# @; 1.23 date 2026.03.08.21.04.54; author christos; state Exp; branches; next 1.22; commitid zc3Yt0P0APInpdxG; 1.22 date 2025.12.18.17.45.29; author christos; state Exp; branches; next 1.21; commitid d1nwFeDpcwSnRUmG; 1.21 date 2025.01.23.22.44.22; author christos; state Exp; branches; next 1.20; commitid GaXXTkWNxH7A6FGF; 1.20 date 2024.09.11.13.50.34; author christos; state Exp; branches; next 1.19; commitid xnprc9mnBSUEsopF; 1.19 date 2024.02.17.14.54.47; author christos; state Exp; branches 1.19.2.1; next 1.18; commitid LUIymdj0oVX6sNYE; 1.18 date 2023.09.16.18.40.26; author christos; state Exp; branches; next 1.17; commitid kE66nx8X6fNBF1FE; 1.17 date 2022.12.11.17.57.23; author christos; state Exp; branches; next 1.16; commitid FpsljNH6VAsCoa5E; 1.16 date 2022.10.29.13.55.50; author christos; state Exp; branches; next 1.15; commitid dHhQ59mUinmarCZD; 1.15 date 2022.08.16.11.07.40; author christos; state Exp; branches; next 1.14; commitid kGTYMXHeGbmnT5QD; 1.14 date 2022.08.16.10.56.21; author christos; state Exp; branches; next 1.13; commitid DeTUBNB0zwKvP5QD; 1.13 date 2022.03.22.17.48.39; author christos; state Exp; branches; next 1.12; commitid gF4k8JjOlfHJPexD; 1.12 date 2021.10.22.14.26.04; author christos; state Exp; branches; next 1.11; commitid VZkJtHtD2eGJyOdD; 1.11 date 2021.03.01.04.42.14; author christos; state Exp; branches; next 1.10; commitid gi1ukb6WxMEUSyJC; 1.10 date 2020.10.09.18.38.48; author christos; state Exp; branches; next 1.9; commitid E1xHzhjtDpg96grC; 1.9 date 2020.05.25.14.52.48; author christos; state Exp; branches; next 1.8; commitid reurqBm7lGqUgD9C; 1.8 date 2019.07.03.15.50.16; author christos; state Exp; branches; next 1.7; commitid Ryam9raFvwL76CtB; 1.7 date 2019.04.04.18.18.31; author christos; state Exp; branches; next 1.6; commitid zvjodTIDyaIjO3iB; 1.6 date 2019.01.01.03.04.56; author christos; state Exp; branches; next 1.5; commitid RHg18Unxy0MiK16B; 1.5 date 2018.10.27.22.29.24; author christos; state Exp; branches; next 1.4; commitid Xw8SzTxFKiMbjEXA; 1.4 date 2018.10.19.23.05.35; author christos; state Exp; branches; next 1.3; commitid bvZuQJpRRMKzLCWA; 1.3 date 2018.05.04.15.51.00; author christos; state Exp; branches 1.3.2.1; next 1.2; commitid rwOAlkvxxlOdLZAA; 1.2 date 2018.01.25.22.48.42; author christos; state Exp; branches 1.2.2.1; next 1.1; commitid cLw6KzpGEaOdejoA; 1.1 date 2017.10.24.17.38.17; author christos; state Exp; branches; next ; commitid euJUPZvsEnlSwkcA; 1.19.2.1 date 2025.08.02.05.54.44; author perseant; state Exp; branches; next ; commitid 23j6GFaDws3O875G; 1.3.2.1 date 2019.06.10.22.05.22; author christos; state Exp; branches; next 1.3.2.2; commitid jtc8rnCzWiEEHGqB; 1.3.2.2 date 2020.04.13.08.03.11; author martin; state Exp; branches; next ; commitid X01YhRUPVUDaec4C; 1.2.2.1 date 2018.05.21.04.35.55; author pgoyette; state Exp; branches; next 1.2.2.2; commitid X5L8kSrBWQcDt7DA; 1.2.2.2 date 2018.10.20.06.58.22; author pgoyette; state Exp; branches; next 1.2.2.3; commitid mTSoqZEZ4arHnFWA; 1.2.2.3 date 2018.11.26.01.52.11; author pgoyette; state Exp; branches; next 1.2.2.4; commitid Zj4q5SspGdKXto1B; 1.2.2.4 date 2019.01.18.08.50.10; author pgoyette; state Exp; branches; next ; commitid Lmlzg3OVT2cd6f8B; desc @@ 1.23 log @Merge 2026a, previous was 2025c Release 2026a - 2026-03-01 22:59:49 -0800 Briefly: Moldova has used EU transition times since 2022. The "right" TZif files are no longer installed by default. -DTZ_RUNTIME_LEAPS=0 disables runtime support for leap seconds. TZif files are no longer limited to 50 bytes of abbreviations. zic is no longer limited to 50 leap seconds. Several integer overflow bugs have been fixed. Changes to past and future timestamps Since 2022 Moldova has observed EU transition times, that is, it has sprung forward at 03:00, not 02:00, and has fallen back at 04:00, not 03:00. (Thanks to Heitor David Pinto.) Changes to data Remove Europe/Chisinau from zonenow.tab, as it now agrees with Europe/Athens for future timestamps. Changes to build procedure The Makefile no longer by default installs an alternate set of TZif files for system clocks that count leap seconds. Install with 'make REDO=posix_right' to get the old default, which is rarely used in major downstream distributions. If your system clock counts leap seconds (contrary to POSIX), it is better to install with 'make REDO=right_only'. This change does not affect the leapseconds file, which is still installed as before. The Makefile's POSIXRULES option, which was declared obsolete in release 2019b, has been removed. The Makefile's build procedure thus no longer optionally installs the obsolete posixrules file. Changes to code Compiling with the new option -DTZ_RUNTIME_LEAPS=0 disables runtime support for leap seconds. Although this conforms to POSIX, shrinks tzcode's attack surface, and is more efficient, it fails to support Internet RFC 9636's leap seconds. zic now can generate, and localtime.c can now use, TZif files that hold up to 256 bytes of abbreviations, counting trailing NULs. The previous limit was 50 bytes, and some tzdata TZif files were already consuming 40 bytes. zic -v warns if it generates a file that exceeds the old 50-byte limit. zic -L can now generate TZif files with more than 50 leap seconds. This helps test TZif readers not limited to 50 leap seconds, as tzcode's localtime.c is; it has little immediate need for practical timekeeping as there have been only 27 leap seconds and possibly there will be no more, due to planned changes to UTC. zic -v warns if its output exceeds the old 50-second limit. localtime.c no longer accesses the posixrules file generated by zic -p. Hence for obsolete and nonconforming settings like TZ="AST4ADT" it now typically falls back on US DST rules, rather than attempting to override this fallback with the contents of the posixrules file. This removes library support that was declared obsolete in release 2019b, and fixes some undefined behavior. (Undefined behavior reported by GitHub user Naveed8951.) The posix2time, posix2time_z, time2posix, and time2posix_z functions now set errno=EOVERFLOW and return ((time_t) -1) if the result is not representable. Formerly they had undefined behavior that could in practice result in crashing, looping indefinitely, or returning an incorrect result. As before, these functions are defined only when localtime.c is compiled with the -DSTD_INSPIRED option. Some other undefined behavior, triggered by TZif files containing outlandish but conforming UT offsets or leap second corrections, has also been fixed. (Some of these bugs reported by Naveed8951.) localtime.c no longer rejects TZif files that exactly fit in its internal structures, fixing off-by-one typos introduced in 2014g. zic no longer generates a no-op transition when simultaneous Rule and Zone changes cancel each other out. This occurs in tzdata only in Asia/Tbilisi on 1997-03-30. (Thanks to Renchunhui for a test case showing the bug.) zic no longer assumes you can fflush a read-only stream. (Problem reported by Christos Zoulas.) zic no longer generates UT offsets equal to -2**31 and localtime.c no longer accepts them, as they can cause trouble in both localtime.c and its callers. RFC 9636 prohibits such offsets. zic -p now warns that the -p option is obsolete and likely ineffective. @ text @ Theory and pragmatics of the tz code and data

Theory and pragmatics of the tz code and data

Scope of the tz database

The tz database attempts to record the history and predicted future of civil time scales. It organizes time zone and daylight saving time data by partitioning the world into timezones whose clocks all agree about timestamps that occur after the POSIX Epoch (1970-01-01 00:00:00 UTC). Although 1970 is a somewhat-arbitrary cutoff, there are significant challenges to moving the cutoff earlier even by a decade or two, due to the wide variety of local practices before computer timekeeping became prevalent. Most timezones correspond to a notable location and the database records all known clock transitions for that location; some timezones correspond instead to a fixed UTC offset.

Each timezone typically corresponds to a geographical region that is smaller than a traditional time zone, because clocks in a timezone all agree after 1970 whereas a traditional time zone merely specifies current standard time. For example, applications that deal with current and future timestamps in the traditional North American mountain time zone can choose from the timezones America/Denver which observes US-style daylight saving time (DST), and America/Phoenix which does not observe DST. Applications that also deal with past timestamps in the mountain time zone can choose from over a dozen timezones, such as America/Boise, America/Edmonton, and America/Hermosillo, each of which currently uses mountain time but differs from other timezones for some timestamps after 1970.

Clock transitions before 1970 are recorded for location-based timezones, because most systems support timestamps before 1970 and could misbehave if data entries were omitted for pre-1970 transitions. However, the database is not designed for and does not suffice for applications requiring accurate handling of all past times everywhere, as it would take far too much effort and guesswork to record all details of pre-1970 civil timekeeping. Although some information outside the scope of the database is collected in a file backzone that is distributed along with the database proper, this file is less reliable and does not necessarily follow database guidelines.

As described below, reference source code for using the tz database is also available. The tz code is upwards compatible with POSIX, an international standard for UNIX-like systems. As of this writing, the current edition of POSIX is POSIX.1-2024 (The Open Group Base Specifications Issue 8, IEEE Std 1003.1-2024). Unlike its predecessors POSIX.1-1988 through POSIX.1-2017, POSIX.1-2024 requires support for the tz database, which has a model for describing civil time that is more complex than the standard and daylight saving times required by earlier POSIX editions. A tz timezone corresponds to a ruleset that can have more than two changes per year, these changes need not merely flip back and forth between two alternatives, and the rules themselves can change at times. Whether and when a timezone changes its clock, and even the timezone’s notional base offset from UTC, are variable. It does not always make sense to talk about a timezone’s “base offset”, which is not necessarily a single number.

Timezone identifiers

Each timezone has a name that uniquely identifies the timezone. Inexperienced users are not expected to select these names unaided. Distributors should provide documentation and/or a simple selection interface that explains each name via a map or via descriptive text like “Czech Republic” instead of the timezone name “Europe/Prague”. If geolocation information is available, a selection interface can locate the user on a timezone map or prioritize names that are geographically close. For an example selection interface, see the tzselect program in the tz code. Unicode’s Common Locale Data Repository (CLDR) contains data that may be useful for other selection interfaces; it maps timezone names like Europe/Prague to locale-dependent strings like “Prague”, “Praha”, “Прага”, and “布拉格”.

The naming conventions attempt to strike a balance among the following goals:

Names normally have the format AREA/LOCATION, where AREA is a continent or ocean, and LOCATION is a specific location within the area. North and South America share the same area, America. Typical names are Africa/Cairo, America/New_York, and Pacific/Honolulu. Some names are further qualified to help avoid confusion; for example, America/Indiana/Petersburg distinguishes Petersburg, Indiana from other Petersburgs in America.

Here are the general guidelines used for choosing timezone names, in decreasing order of importance:

Guidelines have evolved with time, and names following old versions of these guidelines might not follow the current version. When guidelines have changed, old names continue to be supported. Guideline changes have included the following:

The file zone1970.tab lists geographical locations used to name timezones. It is intended to be an exhaustive list of names for geographic regions as described above; this is a subset of the timezones in the data. Although a zone1970.tab location’s longitude corresponds to its local mean time (LMT) offset with one hour for every 15° east longitude, this relationship is not exact. The backward-compatibility file zone.tab is similar but conforms to the older-version guidelines related to ISO 3166-1; it lists only one country code per entry and unlike zone1970.tab it can list names defined in backward. Applications that process only timestamps from now on can instead use the file zonenow.tab, which partitions the world more coarsely, into regions where clocks agree now and in the predicted future; this file is smaller and simpler than zone1970.tab and zone.tab.

The database defines each timezone name to be a zone, or a link to a zone. The source file backward defines links for backward compatibility; it does not define zones. Although backward was originally designed to be optional, nowadays distributions typically use it and no great weight should be attached to whether a link is defined in backward or in some other file. The source file etcetera defines names that may be useful on platforms that do not support proleptic TZ strings like <+08>-8; no other source file other than backward contains links to its zones. One of etcetera’s names is Etc/UTC, used by functions like gmtime to obtain leap second information on platforms that support leap seconds. Another etcetera name, GMT, is used by older code releases.

Time zone abbreviations

When this package is installed, it generates time zone abbreviations like EST to be compatible with human tradition and POSIX. Here are the general guidelines used for choosing time zone abbreviations, in decreasing order of importance:

Application writers should note that these abbreviations are ambiguous in practice: e.g., CST means one thing in China and something else in North America, and IST can refer to time in India, Ireland or Israel. To avoid ambiguity, use numeric UT offsets like -0600 instead of time zone abbreviations like CST.

Accuracy of the tz database

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

Errors in the tz database arise from many sources:

In short, many, perhaps most, of the tz database’s pre-1970 and future timestamps are either wrong or misleading. Any attempt to pass the tz database off as the definition of time should be unacceptable to anybody who cares about the facts. In particular, the tz database’s LMT offsets should not be considered meaningful, and should not prompt creation of timezones merely because two locations differ in LMT or transitioned to standard time at different dates.

Time and date functions

The tz code contains time and date functions that are upwards compatible with those of POSIX. Code compatible with this package is already part of many platforms, where the primary use of this package is to update obsolete time-related files. To do this, you may need to compile the time zone compiler zic supplied with this package instead of using the system zic, since the format of zic’s input is occasionally extended, and a platform may still be shipping an older zic.

In POSIX, time display in a process is controlled by the environment variable TZ, which can have two forms:

POSIX.1-2017 properties and limitations

Some platforms support only the features required by POSIX.1-2017 and earlier editions, and have not yet upgraded to POSIX.1-2024. Code intended to be portable to these platforms must deal with problems that were fixed in later POSIX editions.

POSIX.1-2017 also has the limitations of POSIX.1-2024, discussed in the next section.

POSIX.1-2024 properties and limitations

POSIX.1-2024 extends POSIX.1-2017 in the following significant ways:

However POSIX.1-2024, like earlier POSIX editions, has some limitations:

Extensions to POSIX in the tz code

The tz code defines some properties left unspecified by POSIX, and attempts to support some extensions to POSIX.

POSIX features no longer needed

POSIX and ISO C define some APIs that are vestigial: they are not needed, and are relics of a too-simple model that does not suffice to handle many real-world timestamps. Although the tz code supports these vestigial APIs for backwards compatibility, they should be avoided in portable applications. The vestigial APIs are:

Other portability notes

Interface stability

The tz code and data supply the following interfaces:

Interface changes in a release attempt to preserve compatibility with recent releases. For example, tz data files typically do not rely on recently added zic features, so that users can run older zic versions to process newer data files. Downloading the tz database describes how releases are tagged and distributed.

Interfaces not listed above are less stable. For example, users should not rely on particular UT offsets or abbreviations for timestamps, as data entries are often based on guesswork and these guesses may be corrected or improved.

Timezone boundaries are not part of the stable interface. For example, even though the Asia/Bangkok timezone currently includes Chang Mai, Hanoi, and Phnom Penh, this is not part of the stable interface and the timezone can split at any time. If a calendar application records a future event in some location other than Bangkok by putting Asia/Bangkok in the event’s record, the application should be robust in the presence of timezone splits between now and the future time.

Leap seconds

Leap seconds were introduced in 1972 to accommodate the difference between atomic time and the less regular rotation of the earth. Unfortunately they have caused so many problems with civil timekeeping that there are plans to discontinue them by 2035. Even if these plans come to fruition, a record of leap seconds will still be needed to resolve timestamps from 1972 through 2035, and there may also be a need to record whatever mechanism replaces them.

The tz code and data can account for leap seconds, thanks to code contributed by Bradley White. However, the leap second support of this package is rarely used directly because POSIX requires leap seconds to be excluded and many software packages would mishandle leap seconds if they were present. Instead, leap seconds are more commonly handled by occasionally adjusting the operating system kernel clock as described in Precision timekeeping, and this package by default installs a leapseconds file commonly used by NTP software that adjusts the kernel clock. However, kernel-clock twiddling approximates UTC only roughly, and systems needing more precise UTC can use this package’s leap second support directly.

The directly supported mechanism assumes that time_t counts of seconds since the POSIX epoch normally include leap seconds, as opposed to POSIX time_t counts which exclude leap seconds. This modified timescale is converted to UTC at the same point that time zone and DST adjustments are applied – namely, at calls to localtime and analogous functions – and the process is driven by leap second information stored in alternate versions of the TZif files. Because a leap second adjustment may be needed even if no time zone correction is desired, calls to gmtime-like functions also need to consult a TZif file, conventionally named Etc/UTC (GMT in previous versions), to see whether leap second corrections are needed. To convert an application’s time_t timestamps to or from POSIX time_t timestamps (for use when, say, embedding or interpreting timestamps in portable tar files), the application can call the utility functions time2posix and posix2time included with this package.

If the POSIX-compatible TZif file set is installed in a directory whose basename is zoneinfo, the leap-second-aware file set is by default installed in a separate directory zoneinfo-leaps. Although each process can have its own time zone by setting its TZ environment variable, there is no support for some processes being leap-second aware while other processes are POSIX-compatible; the leap-second choice is system-wide. So if you configure your kernel to count leap seconds, you should also discard zoneinfo and rename zoneinfo-leaps to zoneinfo. Alternatively, you can install just one set of TZif files in the first place; see the REDO variable in this package’s makefile.

Calendrical issues

Calendrical issues are a bit out of scope for a time zone database, but they indicate the sort of problems that we would run into if we extended the time zone database further into the past. An excellent resource in this area is Edward M. Reingold and Nachum Dershowitz, Calendrical Calculations: The Ultimate Edition, Cambridge University Press (2018). Other information and sources are given in the file "calendars" in the tz distribution. They sometimes disagree.

Time and time zones off Earth

The European Space Agency is considering the establishment of a reference timescale for the Moon, which has days roughly equivalent to 29.5 Earth days, and where relativistic effects cause clocks to tick slightly faster than on Earth. Also, NASA has been ordered to consider the establishment of Coordinated Lunar Time (LTC). It is not yet known whether the US and European efforts will result in multiple timescales on the Moon.

Some people’s work schedules have used Mars time. Jet Propulsion Laboratory (JPL) coordinators kept Mars time on and off during the Mars Pathfinder mission (1997). Some of their family members also adapted to Mars time. Dozens of special Mars watches were built for JPL workers who kept Mars time during the Mars Exploration Rovers (MER) mission (2004–2018). These timepieces looked like normal Seikos and Citizens but were adjusted to use Mars seconds rather than terrestrial seconds, although unfortunately the adjusted watches were unreliable and appear to have had only limited use.

A Mars solar day is called a “sol” and has a mean period equal to about 24 hours 39 minutes 35.244 seconds in terrestrial time. It is divided into a conventional 24-hour clock, so each Mars second equals about 1.02749125 terrestrial seconds. (One MER worker noted, “If I am working Mars hours, and Mars hours are 2.5% more than Earth hours, shouldn’t I get an extra 2.5% pay raise?”)

The prime meridian of Mars goes through the center of the crater Airy-0, named in honor of the British astronomer who built the Greenwich telescope that defines Earth’s prime meridian. Mean solar time on the Mars prime meridian is called Mars Coordinated Time (MTC).

Each landed mission on Mars has adopted a different reference for solar timekeeping, so there is no real standard for Mars time zones. For example, the MER mission defined two time zones “Local Solar Time A” and “Local Solar Time B” for its two missions, each zone designed so that its time equals local true solar time at approximately the middle of the nominal mission. The A and B zones differ enough so that an MER worker assigned to the A zone might suffer “Mars lag” when switching to work in the B zone. Such a “time zone” is not particularly suited for any application other than the mission itself.

Many calendars have been proposed for Mars, but none have achieved wide acceptance. Astronomers often use Mars Sol Date (MSD) which is a sequential count of Mars solar days elapsed since about 1873-12-29 12:00 GMT.

In our solar system, Mars is the planet with time and calendar most like Earth’s. On other planets, Sun-based time and calendars would work quite differently. For example, although Mercury’s sidereal rotation period is 58.646 Earth days, Mercury revolves around the Sun so rapidly that an observer on Mercury’s equator would see a sunrise only every 175.97 Earth days, i.e., a Mercury year is 0.5 of a Mercury day. Venus is more complicated, partly because its rotation is slightly retrograde: its year is 1.92 of its days. Gas giants like Jupiter are trickier still, as their polar and equatorial regions rotate at different rates, so that the length of a day depends on latitude. This effect is most pronounced on Neptune, where the day is about 12 hours at the poles and 18 hours at the equator.

Although the tz database does not support time on other planets, it is documented here in the hopes that support will be added eventually.

Sources for time on other planets:

@ 1.22 log @Release 2025c - 2025-12-10 14:42:37 -0800 Briefly: Several code changes for compatibility with FreeBSD. Changes to code An unset TZ is no longer invalid when /etc/localtime is missing, and is abbreviated "UTC" not "-00". This reverts to 2024b behavior. (Problem and patch reported by Dag-Erling Smørgrav.) New function offtime_r, short for fixed-offset localtime_rz. It is defined if STD_INSPIRED is defined. (Patch from Dag-Erling Smørgrav.) tzset etc. are now more cautious about questionable TZ settings. Privileged programs now reject TZ settings that start with '/', unless they are TZDEFAULT (default "/etc/localtime") or start with TZDIR then '/' (default "/usr/share/zoneinfo/"). Unprivileged programs now require files to be regular files and reject relative names containing ".." directory components; formerly, only privileged programs did those two things. These changes were inspired by similar behavior in FreeBSD. On NetBSD, unprivileged programs now use O_REGULAR to check whether a TZ setting starting with '/' names a regular file, avoiding a minor security race still present elsewhere. TZ strings taken from tzalloc arguments are now treated with no less caution than TZ strings taken from the environment, as the old undocumented behavior would have been hard to explain. tzset etc. no longer use the 'access' system call to check access; instead they now use the system calls issetugid, getauxval, getresuid/getresgid, and geteuid/getegid/getuid/getgid (whichever first works) to test whether a program is privileged. Compile with -DHAVE_SYS_AUXV_H=[01] to enable or disable which (if it defines AT_SECURE) enables getauxval, and compile with -DHAVE_ISSETUGID=[01], -DHAVE_GETRESUID=[01], and -DHAVE_GETEUID=[01] to enable or disable the other calls' use. The new CFLAGS option -DTZ_CHANGE_INTERVAL=N makes tzset etc. check for TZif file changes if the in-memory data are N seconds old or more, and are derived from the TZ environment variable. This is intended for platforms that want tzset etc. to reflect changes to whatever file TZ selects (including changes to /etc/localtime if TZ is unset). If N is negative (the default) these checks are omitted; this is the traditional behavior. The new CFLAGS options -DHAVE_STRUCT_STAT_ST_CTIM=0 and -DHAVE_STRUCT_TIMESPEC=0 port to non-POSIX.1-2008 platforms that lack st_ctim and struct timespec, respectively. tzset etc. now treat ' ' like '_' in time zone abbreviations, just as they treat other invalid bytes. This continues the transition begun in release 96k, which removed spaces in tzdata because the spaces break time string parsers. The new CFLAGS option -DTHREAD_PREFER_SINGLE causes tzcode in single-threaded processes to avoid locks, as FreeBSD does. This can save time in single-threaded apps. The threadedness testing costs CPU time and energy in multi-threaded apps. New options -DHAVE___ISTHREADED and -DHAVE_SYS_SINGLE_THREADED_H can help configure how to test for single-threadedness. The new CFLAGS option -DTHREAD_RWLOCK uses read-write locks, as macOS does, instead of mutexes. This saves real time when TZ is rarely changing and many threads call tzcode simultaneously. It costs more CPU time and energy. The new CFLAGS option -TTHREAD_TM_MULTI causes localtime to return a pointer to thread-specific memory, as FreeBSD does, instead of to the same memory in all threads. This supports unportable programs that incorrectly use localtime instead of localtime_r. This option affects gmtime and offtime similarly to localtime. Because the corresponding storage is freed on thread exit, this option is incompatible with POSIX.1-2024 and earlier. It also costs CPU time and memory. tzfree now preserves errno, consistently with POSIX.1-2024 'free'. tzcode now uses mempcpy if available, guessing its availability. Compile with -DHAVE_MEMPCPY=1 or 0 to override the guess. tzcode now uses strnlen to improve asymptotic performance a bit. Compile with -DHAVE_STRNLEN=0 if your platform lacks it. tzcode now hand-declares unistd.h-provided symbols like getopt if HAVE_UNISTD_H=0, not if HAVE_POSIX_DECLS=0. tzset etc. now have an experimental OPENAT_TZDIR option; see Makefile and localtime.c for details. On platforms like GNU/Hurd that do not define PATH_MAX, exceedingly long TZ strings no longer fail merely because they exceed an arbitrary file name length limit imposed by tzcode. zic has new options inspired by FreeBSD. '-D' skips creation of output ancestor directories, '-m MODE' sets output files' mode, and '-u OWNER[:GROUP]' sets output files' owner and group. zic now uses the fdopen function, which was standardized by POSIX.1-1988 and is now safe to use in portable code. This replaces its use of the older umask function, which complicated maintenance. @ text @d6 1 d8 3 a10 1 pre {margin-left: 2em; white-space: pre-wrap;} a15 1

Outline

d653 1 a653 1 href="https://www.hup.harvard.edu/catalog.php?isbn=9780674286146">The d660 1 a660 1 href="https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle">Booked: d794 1 a794 1 href="https://theworld.org/stories/2015-01-30/if-you-have-meeting-ethiopia-you-better-double-check-time">the d1131 1 a1131 1 Internet d1443 1 a1443 1 href="https://www.cambridge.org/fr/academic/subjects/computer-science/computing-general-interest/calendrical-calculations-ultimate-edition-4th-edition">Calendrical d1455 1 a1455 1 href="https://www.esa.int/Applications/Navigation/Telling_time_on_the_Moon">considering d1461 1 a1461 1 href="https://www.whitehouse.gov/wp-content/uploads/2024/04/Celestial-Time-Standardization-Policy.pdf">ordered d1581 1 a1581 1 “How @ 1.21 log @update to 2025a Changes to code strftime %s now generates the correct numeric string even when the represented number does not fit into time_t. This is better than generating the numeric equivalent of (time_t) -1, as strftime did in TZDB releases 96a (when %s was introduced) through 2020a and in releases 2022b through 2024b. It is also better than failing and returning 0, as strftime did in releases 2020b through 2022a. strftime now outputs an invalid conversion specifier as-is, instead of eliding the leading '%', which confused debugging. An invalid TZ now generates the time zone abbreviation "-00", not "UTC", to help the user see that an error has occurred. (Thanks to Arthur David Olson for suggesting a "wrong result".) mktime and timeoff no longer incorrectly fail merely because a struct tm component near INT_MIN or INT_MAX overflows when a lower-order component carries into it. TZNAME_MAXIMUM, the maximum number of bytes in a proleptic TZ string's time zone abbreviation, now defaults to 254 not 255. This helps reduce the size of internal state from 25480 to 21384 on common platforms. This change should not be a problem, as nobody uses such long "abbreviations" and the longstanding tzcode maximum was 16 until release 2023a. For those who prefer no arbitrary limits, you can now specify TZNAME_MAXIMUM values up to PTRDIFF_MAX, a limit forced by C anyway; formerly tzcode silently misbehaved unless TZNAME_MAXIMUM was less than INT_MAX. tzset and related functions no longer leak a file descriptor if another thread forks or execs at about the same time and if the platform has O_CLOFORK and O_CLOEXEC respectively. Also, the functions no longer let a TZif file become a controlling terminal. 'zdump -' now reads TZif data from /dev/stdin. (From a question by Arthur David Olson.) @ text @d92 7 a98 6 As of this writing, the current edition of POSIX is POSIX.1-2024, which has been published but not yet in HTML form. Unlike its predecessor POSIX.1-2017 ( The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2017, 2018 Edition), POSIX.1-2024 requires support for the d101 1 a101 1 standard and daylight saving times required by POSIX.1-2017. d107 1 a107 1 and even the timezone's notional base offset from UTC, d109 2 a110 2 It does not always make sense to talk about a timezone's "base offset", which is not necessarily a single number. d122 1 a122 1 "Czech Republic" instead of the timezone name "Europe/Prague". d127 1 a127 1 Unicode's Common Locale Data d131 1 a131 1 locale-dependent strings like "Prague", "Praha", "Прага", and "布拉格". d146 1 a146 1 Indicate to experts where the timezone's clocks typically are. d152 1 a152 1 Swaziland→Eswatini) or when locations change countries (e.g., Hong d170 3 a172 3 North and South America share the same area, 'America'. Typical names are 'Africa/Cairo', 'America/New_York', and 'Pacific/Honolulu'. d174 1 a174 1 'America/Indiana/Petersburg' distinguishes Petersburg, d187 3 a189 3 names other than '/'). Do not use the file name components '.' and '..'. d192 1 a192 1 '.', '-' and '_'. d194 2 a195 2 href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03">POSIX's proleptic TZ strings. d197 1 a197 1 '-'. d203 3 a205 3 A name must not be empty, or contain '//', or start or end with '/'. Also, a name must not be 'Etc/Unknown', as d217 1 a217 1 start with '/', as a regular file cannot have the d284 2 a285 2 Omit common suffixes like '_Islands' and '_City', unless that would lead to ambiguity. d296 1 a296 1 Use '_' to represent a space. d299 1 a299 1 Omit '.' from abbreviations in names. d307 2 a308 2 Europe/Milan merely because Milan's population has grown to be somewhat greater than Rome's. d312 1 a312 1 'backward' file as a link to the new spelling. d315 1 a315 1 a location's consensus English-language spelling changes; for example, d331 2 a332 2 See the file 'backward' for most of these older names (e.g., 'US/Eastern' instead of 'America/New_York'). d334 2 a335 2 'WET', 'CET', 'MET', and 'EET' (see the file 'europe'). d343 7 a349 7 'etcetera'. Also, the file 'backward' defines the legacy names 'Etc/GMT0', 'Etc/GMT-0', 'Etc/GMT+0', 'GMT0', 'GMT-0' and 'GMT+0', and the file 'northamerica' defines the legacy names 'EST5EDT', 'CST6CDT', 'MST7MDT', and 'PST8PDT'. d369 1 a369 1 Although a zone1970.tab location's d373 1 a373 1 time (LMT) offset with one hour for every 15° d399 1 a399 1 One of etcetera's names is Etc/UTC, d411 1 a411 1 like 'EST' to be compatible with human tradition and POSIX. d419 1 a419 1 '+' or '-'. d421 1 a421 1 space and '?', but these characters have a d425 2 a426 2 'set `date`' d431 3 a433 4 Standard Time preferred "ChST", so lower-case letters are now allowed. Also, POSIX from 2001 on relaxed the rule to allow '-', '+', and alphanumeric characters from the portable d435 2 a436 2 In practice ASCII alphanumerics and '+' and '-' are safe in all locales. d448 1 a448 1 e.g., 'EST' for Eastern Standard Time in North America. d451 1 a451 1 a French application might translate 'EST' to 'HNE'. d486 1 a486 1 NZST/NZDT New Zealand 1946–present, d503 1 a503 1 For times taken from a city's longitude, use the d505 1 a505 1 The only abbreviation like this in current use is 'GMT'. d508 1 a508 1 Typically, numeric abbreviations (e.g., '-004430' for d549 1 a549 1 BMT/BST for Bermuda 1890–1930, d551 1 a551 1 1890–1932, d553 3 a555 3 1880–1916, MMT/MST/MDST for Moscow 1880–1919, and RMT/LST for Riga Mean Time and Latvian Summer time 1880–1926. d560 3 a562 3 Use 'LMT' for local mean time of locations before the introduction of standard time; see "Scope of the tz database". d567 1 a567 1 by zic's %z notation. d572 4 a575 4 in central Europe was 'MEZ' (short for both "Middle European Zone" and for "Mitteleuropäische Zeit" in German). Nowadays 'CET' ("Central European Time") is more common in English, and the database uses 'CET' even for circa-1910 d577 1 a577 1 the need for determining when 'CET' supplanted 'MEZ' in common d581 1 a581 1 Use a consistent style in a timezone's history. d589 1 a589 1 (UT) (with time zone abbreviation '-00') for d591 1 a591 1 The leading '-' is a flag that the UT offset is in d595 1 a595 1 (The abbreviation 'Z' that d605 2 a606 2 in practice: e.g., 'CST' means one thing in China and something else in North America, and 'IST' can refer to time in India, Ireland or d609 1 a609 1 '-0600' instead of time zone abbreviations like 'CST'. d620 1 a620 1 bodies and the references cited in the database's comments. d642 1 a642 1 the tz database's scope were extended to d652 1 a652 1 Global Transformation of Time, 1870–1950, d654 1 a654 1 "Outside of Europe and North America there was no system of time d656 1 a656 1 prior to the middle decades of the twentieth century". d674 2 a675 2 "History of legal time in Britain". d700 1 a700 1 have London's exact meridian, and its 1847 transition d706 1 a706 1 earliest time for which a timezone's d717 1 a717 1 region's boundaries, and in many cases the boundaries are not known. d750 1 a750 1 −00:25:21.1); although the tz d790 1 a790 1 relatively minor, such as Japanese bars giving times like "24:30" for the d828 1 a828 1 earth's d834 4 a837 4 See: Stephenson FR, Morrison LV, Hohenkerk CY. Measurement of the Earth's rotation: 720 BC to AD 2015. Proc Royal Soc A. 2016;472:20160404. d846 1 a846 1 This affects time stamps during the leap second era (1972–2035). d865 1 a865 1 database's pre-1970 and future timestamps are either wrong or d870 1 a870 1 In particular, the tz database's d889 1 a889 1 system zic, since the format of zic's d917 2 a918 1 Some platforms support only the features required by POSIX.1-2017, d960 1 a960 1 may also be in a quoted form like '<+09>'; d965 1 a965 1 '[±]hh:[mm[:ss]]' d967 1 a967 1 'hh' may be a single digit; d980 1 a980 1 'hh:[mm[:ss]]' d983 1 a983 1 leading '+' or '-' is not allowed. d1000 1 a1000 1 '5' stands for the last week in which d1015 2 a1016 2 (NZDT) is observed from September's last Sunday at 02:00 until April's first Sunday at 03:00: d1052 1 a1052 1 DST transition times can range from −167:59:59 d1056 1 a1056 1 where the transition time −1:00 means 23:00 the previous day. d1069 1 a1069 1 system's best idea of local (wall clock) time. d1071 1 a1071 1 used only at certain times – without regard to whether the d1074 1 a1074 1 While an administrator can "do everything in UT" to d1076 1 a1076 1 handling daylight saving time shifts – as might be required to d1085 1 a1085 2 for TZ values like "EST5EDT". d1127 1 a1127 1 The file's format is TZif, d1141 2 a1142 2 variable to take on values such as 'America/New_York' might cause "old" programs (that expect TZ to have a d1145 1 a1145 1 to hold the string used to generate the TZif file's name. d1150 3 a1152 3 "new" forms of TZ might cause problems can simply use legacy TZ values such as "EST5EDT" which can be used by "new" programs as well as by "old" programs that d1195 1 a1195 1 To get a timestamp's time zone abbreviation, consult d1197 1 a1197 1 use strftime's "%Z" conversion d1204 1 a1204 1 To get a timestamp's UT offset, consult d1208 1 a1208 1 or use strftime's "%z" conversion d1233 3 a1235 3 package; it is impossible to reliably map timezone's arguments (a "minutes west of GMT" value and a "daylight saving time in effect" flag) to a time zone d1265 1 a1265 1 They are not in any sense "standard compatible" – some are d1296 1 a1296 1 "Timezone identifiers" above. d1299 2 a1300 2 Library functions described in "Time and date functions" above. d1322 1 a1322 1 the text file 'version' in each release. d1350 1 a1350 1 than Bangkok by putting "Asia/Bangkok" in the event's record, d1384 1 a1384 1 and systems needing more precise UTC can use this package's leap d1394 2 a1395 2 adjustments are applied – namely, at calls to localtime and analogous functions – d1405 1 a1405 1 To convert an application's time_t timestamps to or from d1428 1 a1428 1 in the first place; see the REDO variable in this package's d1443 1 a1443 1 Other information and sources are given in the file 'calendars' d1453 1 a1453 1 href='https://www.esa.int/Applications/Navigation/Telling_time_on_the_Moon'>considering d1459 1 a1459 1 href='https://www.whitehouse.gov/wp-content/uploads/2024/04/Celestial-Time-Standardization-Policy.pdf'>ordered d1466 1 a1466 1 Some people's work schedules have used d1476 1 a1476 1 Exploration Rovers (MER) mission (2004–2018). d1484 1 a1484 1 A Mars solar day is called a "sol" and has a mean period equal to d1488 2 a1489 2 (One MER worker noted, "If I am working Mars hours, and Mars hours are 2.5% more than Earth hours, shouldn't I get an extra 2.5% pay raise?") d1497 1 a1497 1 defines Earth's prime meridian. d1505 2 a1506 2 For example, the MER mission defined two time zones "Local Solar Time A" and "Local Solar Time B" for its two missions, each zone d1510 2 a1511 2 the A zone might suffer "Mars lag" when switching to work in the B zone. Such a "time zone" is not particularly suited for any application d1525 1 a1525 1 like Earth's. d1528 1 a1528 1 For example, although Mercury's d1531 1 a1531 1 Sun so rapidly that an observer on Mercury's equator would see a d1557 2 a1558 2 "Technical Notes on Mars Solar Time as Adopted by the Mars24 Sunclock" d1568 3 a1570 3 "Workdays Fit for a Martian", Los Angeles Times (2004-01-14), pp A1, A20–A21. d1574 2 a1575 2 "Jet Lag Is Worse on Mars", The Atlantic (2015-02-26) d1579 2 a1580 2 "How long is a day on the other planets of the solar system?" d1587 8 a1594 3
This file is in the public domain, so clarified as of 2009-05-17 by Arthur David Olson. @ 1.20 log @ Merge tzcode-2024b Release 2024b - 2024-09-04 12:27:47 -0700 Changes to code localtime.c now always uses a TZif file's time type 0 to handle timestamps before the file's first transition. Formerly, localtime.c sometimes inferred a different time type, in order to handle problematic data generated by zic 2018e or earlier. As it is now safe to assume more recent versions of zic, there is no longer a pressing need to fail to conform RFC 8536 section 3.2, which requires using time type 0 in this situation. This change does not affect behavior when reading TZif files generated by zic 2018f and later. POSIX.1-2024 removes asctime_r and ctime_r and does not let libraries define them, so remove them except when needed to conform to earlier POSIX. These functions are dangerous as they can overrun user buffers. If you still need them, add -DSUPPORT_POSIX2008 to CFLAGS. The SUPPORT_C89 option now defaults to 1 instead of 0, fixing a POSIX-conformance bug introduced in 2023a. tzselect now supports POSIX.1-2024 proleptic TZ strings. Also, it assumes POSIX.2-1992 or later, as practical porting targets now all support that, and it uses some features from POSIX.1-2024 if available. Changes to build procedure 'make check' no longer requires curl and Internet access. The build procedure now assumes POSIX.2-1992 or later, to simplify maintenance. To build on Solaris 10, the only extant system still defaulting to pre-POSIX, prepend /usr/xpg4/bin to PATH. Changes to documentation The documentation now reflects POSIX.1-2024. Changes to commentary Commentary about historical transitions in Portugal and her former colonies has been expanded with links to many relevant legislation. (Thanks to Tim Parenti.) @ text @d126 3 a128 2 The Unicode Common Locale Data Repository contains data that may be useful for other selection d204 2 d226 3 a228 3 If all the clocks in a timezone have agreed since 1970, do not bother to include more than one timezone even if some of the clocks disagreed before 1970. d230 8 d593 1 a593 1 from Internet d596 1 a596 1 Internet d1129 2 a1130 2 Internet RFC 8536. d1215 2 d1221 3 a1223 2 disambiguation does not work when standard time itself jumps back, which can occur when a location changes to a time zone with a d1240 2 a1241 2 tzname[localtime(&clock)->tm_isdst] (if HAVE_TZNAME is nonzero) to learn the correct time @ 1.19 log @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.) @ text @d92 3 a94 1 As of this writing, the current edition of POSIX is: POSIX.1-2017 d383 2 a384 1 on platforms that do not support POSIX.1-2017-style TZ strings; d431 2 a432 2 This guarantees that all abbreviations could have been specified by a POSIX.1-2017 TZ string. d584 5 d786 1 a786 1 such as that required by POSIX.1-2017. d877 2 a878 2 'zic' supplied with this package instead of using the system 'zic', since the format of zic's d883 4 a886 1

POSIX.1-2017 properties and limitations

d889 32 d922 4 a925 6 In POSIX.1-2017, time display in a process is controlled by the environment variable TZ. Unfortunately, the POSIX.1-2017 TZ string takes a form that is hard to describe and is error-prone in practice. Also, POSIX.1-2017 TZ strings cannot deal with daylight d932 1 a932 1 The POSIX.1-2017 TZ string takes the following form: d999 1 a999 1 Here is an example POSIX.1-2017 TZ string for New d1010 1 a1010 1 This POSIX.1-2017 TZ string is hard to remember, and d1012 1 a1012 1 With this package you can use this instead: d1017 22 d1040 5 a1044 11 POSIX does not define the DST transitions for TZ values like "EST5EDT". Traditionally the current US DST rules were used to interpret such values, but this meant that the US DST rules were compiled into each time conversion package, and when US time conversion rules changed (as in the United States in 1987 and again in 2007), all packages that interpreted TZ values had to be updated to ensure proper results. d1046 4 d1068 2 a1069 4 POSIX.1-2017 provides no convenient and efficient way to determine the UT offset and time zone abbreviation of arbitrary timestamps, particularly for timezones that do not fit into the POSIX model. d1072 11 a1082 2 POSIX requires that time_t clock counts exclude leap seconds. d1084 11 d1108 1 a1108 1 and POSIX.1-2013 and the tz code both a1110 5

Extensions to POSIX.1-2017 in the tz code

POSIX.1-2017 properties and limitations

Some platforms support only the features required by POSIX.1-2017, and have not yet upgraded to POSIX.1-2024. Code intended to be portable to these platforms must deal with problems that were fixed in later POSIX editions.

POSIX.1-2017 also has the limitations of POSIX.1-2024, discussed in the next section.

POSIX.1-2024 properties and limitations

POSIX.1-2024 extends POSIX.1-2017 in the following significant ways:

However POSIX.1-2024, like earlier POSIX editions, has some limitations:

Extensions to POSIX in the tz code

The tz code defines some properties left unspecified by POSIX, and attempts to support some extensions to POSIX.

[The remaining guidelines predate the introduction of %z. They are problematic as they mean tz data entries invent notation rather than record it. These guidelines are now deprecated and the plan is to gradually move to %z for inhabited locations and to "-00" for uninhabited locations.]