theory.html revision 1.18
11.4Schristos<!DOCTYPE html>
21.1Schristos<html lang="en">
31.1Schristos<head>
41.1Schristos  <title>Theory and pragmatics of the tz code and data</title>
51.1Schristos  <meta charset="UTF-8">
61.4Schristos  <style>
71.4Schristos    pre {margin-left: 2em; white-space: pre-wrap;}
81.4Schristos  </style>
91.1Schristos</head>
101.1Schristos
111.1Schristos<body>
121.3Schristos<h1>Theory and pragmatics of the <code><abbr>tz</abbr></code> code and data</h1>
131.1Schristos  <h3>Outline</h3>
141.1Schristos  <nav>
151.1Schristos    <ul>
161.3Schristos      <li><a href="#scope">Scope of the <code><abbr>tz</abbr></code>
171.3Schristos	  database</a></li>
181.7Schristos      <li><a href="#naming">Timezone identifiers</a></li>
191.1Schristos      <li><a href="#abbreviations">Time zone abbreviations</a></li>
201.3Schristos      <li><a href="#accuracy">Accuracy of the <code><abbr>tz</abbr></code>
211.3Schristos	  database</a></li>
221.1Schristos      <li><a href="#functions">Time and date functions</a></li>
231.1Schristos      <li><a href="#stability">Interface stability</a></li>
241.9Schristos      <li><a href="#leapsec">Leap seconds</a></li>
251.1Schristos      <li><a href="#calendar">Calendrical issues</a></li>
261.18Schristos      <li><a href="#planets">Time and time zones off earth</a></li>
271.1Schristos    </ul>
281.1Schristos  </nav>
291.1Schristos
301.3Schristos<section>
311.3Schristos  <h2 id="scope">Scope of the <code><abbr>tz</abbr></code> database</h2>
321.1Schristos<p>
331.3SchristosThe <a
341.3Schristoshref="https://www.iana.org/time-zones"><code><abbr>tz</abbr></code>
351.3Schristosdatabase</a> attempts to record the history and predicted future of
361.10Schristoscivil time scales.
371.3SchristosIt organizes <a href="tz-link.html">time zone and daylight saving time
381.3Schristosdata</a> by partitioning the world into <a
391.4Schristoshref="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"><dfn>timezones</dfn></a>
401.3Schristoswhose clocks all agree about timestamps that occur after the <a
411.3Schristoshref="https://en.wikipedia.org/wiki/Unix_time">POSIX Epoch</a>
421.3Schristos(1970-01-01 00:00:00 <a
431.3Schristoshref="https://en.wikipedia.org/wiki/Coordinated_Universal_Time"><abbr
441.3Schristostitle="Coordinated Universal Time">UTC</abbr></a>).
451.3SchristosAlthough 1970 is a somewhat-arbitrary cutoff, there are significant
461.3Schristoschallenges to moving the cutoff earlier even by a decade or two, due
471.3Schristosto the wide variety of local practices before computer timekeeping
481.3Schristosbecame prevalent.
491.12SchristosMost timezones correspond to a notable location and the database
501.12Schristosrecords all known clock transitions for that location;
511.12Schristossome timezones correspond instead to a fixed <abbr>UTC</abbr> offset.
521.1Schristos</p>
531.1Schristos
541.1Schristos<p>
551.4SchristosEach timezone typically corresponds to a geographical region that is
561.4Schristossmaller than a traditional time zone, because clocks in a timezone
571.4Schristosall agree after 1970 whereas a traditional time zone merely
581.4Schristosspecifies current standard time. For example, applications that deal
591.4Schristoswith current and future timestamps in the traditional North
601.4SchristosAmerican mountain time zone can choose from the timezones
611.4Schristos<code>America/Denver</code> which observes US-style daylight saving
621.12Schristostime (<abbr>DST</abbr>),
631.12Schristosand <code>America/Phoenix</code> which does not observe <abbr>DST</abbr>.
641.4SchristosApplications that also deal with past timestamps in the mountain time
651.4Schristoszone can choose from over a dozen timezones, such as
661.4Schristos<code>America/Boise</code>, <code>America/Edmonton</code>, and
671.4Schristos<code>America/Hermosillo</code>, each of which currently uses mountain
681.4Schristostime but differs from other timezones for some timestamps after 1970.
691.4Schristos</p>
701.4Schristos
711.4Schristos<p>
721.12SchristosClock transitions before 1970 are recorded for location-based timezones,
731.1Schristosbecause most systems support timestamps before 1970 and could
741.1Schristosmisbehave if data entries were omitted for pre-1970 transitions.
751.1SchristosHowever, the database is not designed for and does not suffice for
761.1Schristosapplications requiring accurate handling of all past times everywhere,
771.1Schristosas it would take far too much effort and guesswork to record all
781.1Schristosdetails of pre-1970 civil timekeeping.
791.3SchristosAlthough some information outside the scope of the database is
801.2Schristoscollected in a file <code>backzone</code> that is distributed along
811.2Schristoswith the database proper, this file is less reliable and does not
821.2Schristosnecessarily follow database guidelines.
831.1Schristos</p>
841.1Schristos
851.1Schristos<p>
861.3SchristosAs described below, reference source code for using the
871.3Schristos<code><abbr>tz</abbr></code> database is also available.
881.3SchristosThe <code><abbr>tz</abbr></code> code is upwards compatible with <a
891.3Schristoshref="https://en.wikipedia.org/wiki/POSIX">POSIX</a>, an international
901.3Schristosstandard for <a
911.3Schristoshref="https://en.wikipedia.org/wiki/Unix">UNIX</a>-like systems.
921.3SchristosAs of this writing, the current edition of POSIX is: <a
931.8Schristoshref="https://pubs.opengroup.org/onlinepubs/9699919799/"> The Open
941.3SchristosGroup Base Specifications Issue 7</a>, IEEE Std 1003.1-2017, 2018
951.3SchristosEdition.
961.3SchristosBecause the database's scope encompasses real-world changes to civil
971.3Schristostimekeeping, its model for describing time is more complex than the
981.3Schristosstandard and daylight saving times supported by POSIX.
991.4SchristosA <code><abbr>tz</abbr></code> timezone corresponds to a ruleset that can
1001.3Schristoshave more than two changes per year, these changes need not merely
1011.3Schristosflip back and forth between two alternatives, and the rules themselves
1021.3Schristoscan change at times.
1031.9SchristosWhether and when a timezone changes its clock,
1041.9Schristosand even the timezone's notional base offset from <abbr>UTC</abbr>,
1051.9Schristosare variable.
1061.4SchristosIt does not always make sense to talk about a timezone's
1071.4Schristos"base offset", which is not necessarily a single number.
1081.1Schristos</p>
1091.1Schristos
1101.3Schristos</section>
1111.1Schristos
1121.3Schristos<section>
1131.7Schristos  <h2 id="naming">Timezone identifiers</h2>
1141.1Schristos<p>
1151.7SchristosEach timezone has a name that uniquely identifies the timezone.
1161.1SchristosInexperienced users are not expected to select these names unaided.
1171.1SchristosDistributors should provide documentation and/or a simple selection
1181.4Schristosinterface that explains each name via a map or via descriptive text like
1191.10Schristos"Czech Republic" instead of the timezone name "<code>Europe/Prague</code>".
1201.4SchristosIf geolocation information is available, a selection interface can
1211.4Schristoslocate the user on a timezone map or prioritize names that are
1221.4Schristosgeographically close. For an example selection interface, see the
1231.3Schristos<code>tzselect</code> program in the <code><abbr>tz</abbr></code> code.
1241.15SchristosThe <a href="https://cldr.unicode.org">Unicode Common Locale Data
1251.3SchristosRepository</a> contains data that may be useful for other selection
1261.10Schristosinterfaces; it maps timezone names like <code>Europe/Prague</code> to
1271.10Schristoslocale-dependent strings like "Prague", "Praha", "Прага", and "布拉格".
1281.1Schristos</p>
1291.1Schristos
1301.1Schristos<p>
1311.3SchristosThe naming conventions attempt to strike a balance
1321.1Schristosamong the following goals:
1331.1Schristos</p>
1341.3Schristos
1351.1Schristos<ul>
1361.1Schristos  <li>
1371.4Schristos    Uniquely identify every timezone where clocks have agreed since 1970.
1381.3Schristos    This is essential for the intended use: static clocks keeping local
1391.3Schristos    civil time.
1401.1Schristos  </li>
1411.1Schristos  <li>
1421.4Schristos    Indicate to experts where the timezone's clocks typically are.
1431.1Schristos  </li>
1441.1Schristos  <li>
1451.3Schristos    Be robust in the presence of political changes.
1461.7Schristos    For example, names are typically not tied to countries, to avoid
1471.3Schristos    incompatibilities when countries change their name (e.g.,
1481.7Schristos    Swaziland&rarr;Eswatini) or when locations change countries (e.g., Hong
1491.3Schristos    Kong from UK colony to China).
1501.7Schristos    There is no requirement that every country or national
1511.7Schristos    capital must have a timezone name.
1521.1Schristos  </li>
1531.1Schristos  <li>
1541.3Schristos    Be portable to a wide variety of implementations.
1551.1Schristos  </li>
1561.1Schristos  <li>
1571.3Schristos    Use a consistent naming conventions over the entire world.
1581.1Schristos  </li>
1591.1Schristos</ul>
1601.3Schristos
1611.1Schristos<p>
1621.3SchristosNames normally have the form
1631.3Schristos<var>AREA</var><code>/</code><var>LOCATION</var>, where
1641.4Schristos<var>AREA</var> is a continent or ocean, and
1651.4Schristos<var>LOCATION</var> is a specific location within the area.
1661.3SchristosNorth and South America share the same area, '<code>America</code>'.
1671.3SchristosTypical names are '<code>Africa/Cairo</code>',
1681.3Schristos'<code>America/New_York</code>', and '<code>Pacific/Honolulu</code>'.
1691.3SchristosSome names are further qualified to help avoid confusion; for example,
1701.3Schristos'<code>America/Indiana/Petersburg</code>' distinguishes Petersburg,
1711.3SchristosIndiana from other Petersburgs in America.
1721.1Schristos</p>
1731.1Schristos
1741.1Schristos<p>
1751.3SchristosHere are the general guidelines used for
1761.4Schristoschoosing timezone names,
1771.1Schristosin decreasing order of importance:
1781.1Schristos</p>
1791.3Schristos
1801.1Schristos<ul>
1811.1Schristos  <li>
1821.3Schristos    Use only valid POSIX file name components (i.e., the parts of
1831.3Schristos    names other than '<code>/</code>').
1841.3Schristos    Do not use the file name components '<code>.</code>' and
1851.3Schristos    '<code>..</code>'.
1861.3Schristos    Within a file name component, use only <a
1871.3Schristos    href="https://en.wikipedia.org/wiki/ASCII">ASCII</a> letters,
1881.3Schristos    '<code>.</code>', '<code>-</code>' and '<code>_</code>'.
1891.3Schristos    Do not use digits, as that might create an ambiguity with <a
1901.8Schristos    href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03">POSIX
1911.3Schristos    <code>TZ</code> strings</a>.
1921.3Schristos    A file name component must not exceed 14 characters or start with
1931.3Schristos    '<code>-</code>'.
1941.12Schristos    E.g., prefer <code>America/Noronha</code> to
1951.12Schristos    <code>America/Fernando_de_Noronha</code>.
1961.3Schristos    Exceptions: see the discussion of legacy names below.
1971.1Schristos  </li>
1981.1Schristos  <li>
1991.3Schristos    A name must not be empty, or contain '<code>//</code>', or
2001.3Schristos    start or end with '<code>/</code>'.
2011.1Schristos  </li>
2021.1Schristos  <li>
2031.3Schristos    Do not use names that differ only in case.
2041.3Schristos    Although the reference implementation is case-sensitive, some
2051.3Schristos    other implementations are not, and they would mishandle names
2061.3Schristos    differing only in case.
2071.1Schristos  </li>
2081.1Schristos  <li>
2091.3Schristos    If one name <var>A</var> is an initial prefix of another
2101.3Schristos    name <var>AB</var> (ignoring case), then <var>B</var> must not
2111.3Schristos    start with '<code>/</code>', as a regular file cannot have the
2121.3Schristos    same name as a directory in POSIX.
2131.3Schristos    For example, <code>America/New_York</code> precludes
2141.3Schristos    <code>America/New_York/Bronx</code>.
2151.1Schristos  </li>
2161.1Schristos  <li>
2171.3Schristos    Uninhabited regions like the North Pole and Bouvet Island
2181.3Schristos    do not need locations, since local time is not defined there.
2191.1Schristos  </li>
2201.1Schristos  <li>
2211.4Schristos    If all the clocks in a timezone have agreed since 1970,
2221.4Schristos    do not bother to include more than one timezone
2231.4Schristos    even if some of the clocks disagreed before 1970.
2241.3Schristos    Otherwise these tables would become annoyingly large.
2251.1Schristos  </li>
2261.1Schristos  <li>
2271.7Schristos    If boundaries between regions are fluid, such as during a war or
2281.7Schristos    insurrection, do not bother to create a new timezone merely
2291.7Schristos    because of yet another boundary change. This helps prevent table
2301.7Schristos    bloat and simplifies maintenance.
2311.7Schristos  </li>
2321.7Schristos  <li>
2331.3Schristos    If a name is ambiguous, use a less ambiguous alternative;
2341.3Schristos    e.g., many cities are named San José and Georgetown, so
2351.3Schristos    prefer <code>America/Costa_Rica</code> to
2361.3Schristos    <code>America/San_Jose</code> and <code>America/Guyana</code>
2371.3Schristos    to <code>America/Georgetown</code>.
2381.1Schristos  </li>
2391.1Schristos  <li>
2401.3Schristos    Keep locations compact.
2411.3Schristos    Use cities or small islands, not countries or regions, so that any
2421.3Schristos    future changes do not split individual locations into different
2431.4Schristos    timezones.
2441.3Schristos    E.g., prefer <code>Europe/Paris</code> to <code>Europe/France</code>,
2451.3Schristos    since
2461.3Schristos    <a href="https://en.wikipedia.org/wiki/Time_in_France#History">France
2471.3Schristos    has had multiple time zones</a>.
2481.1Schristos  </li>
2491.1Schristos  <li>
2501.3Schristos    Use mainstream English spelling, e.g., prefer
2511.4Schristos    <code>Europe/Rome</code> to <code>Europa/Roma</code>, and
2521.3Schristos    prefer <code>Europe/Athens</code> to the Greek
2531.4Schristos    <code>Ευρώπη/Αθήνα</code> or the Romanized
2541.4Schristos    <code>Evrópi/Athína</code>.
2551.3Schristos    The POSIX file name restrictions encourage this guideline.
2561.1Schristos  </li>
2571.1Schristos  <li>
2581.3Schristos    Use the most populous among locations in a region,
2591.3Schristos    e.g., prefer <code>Asia/Shanghai</code> to
2601.3Schristos    <code>Asia/Beijing</code>.
2611.3Schristos    Among locations with similar populations, pick the best-known
2621.3Schristos    location, e.g., prefer <code>Europe/Rome</code> to
2631.3Schristos    <code>Europe/Milan</code>.
2641.1Schristos  </li>
2651.1Schristos  <li>
2661.3Schristos    Use the singular form, e.g., prefer <code>Atlantic/Canary</code> to
2671.3Schristos    <code>Atlantic/Canaries</code>.
2681.1Schristos  </li>
2691.1Schristos  <li>
2701.3Schristos    Omit common suffixes like '<code>_Islands</code>' and
2711.3Schristos    '<code>_City</code>', unless that would lead to ambiguity.
2721.3Schristos    E.g., prefer <code>America/Cayman</code> to
2731.3Schristos    <code>America/Cayman_Islands</code> and
2741.3Schristos    <code>America/Guatemala</code> to
2751.3Schristos    <code>America/Guatemala_City</code>, but prefer
2761.3Schristos    <code>America/Mexico_City</code> to
2771.3Schristos    <code>America/Mexico</code>
2781.3Schristos    because <a href="https://en.wikipedia.org/wiki/Time_in_Mexico">the
2791.3Schristos    country of Mexico has several time zones</a>.
2801.1Schristos  </li>
2811.1Schristos  <li>
2821.3Schristos    Use '<code>_</code>' to represent a space.
2831.1Schristos  </li>
2841.1Schristos  <li>
2851.3Schristos    Omit '<code>.</code>' from abbreviations in names.
2861.3Schristos    E.g., prefer <code>Atlantic/St_Helena</code> to
2871.3Schristos    <code>Atlantic/St._Helena</code>.
2881.1Schristos  </li>
2891.1Schristos  <li>
2901.3Schristos    Do not change established names if they only marginally violate
2911.3Schristos    the above guidelines.
2921.3Schristos    For example, do not change the existing name <code>Europe/Rome</code> to
2931.3Schristos    <code>Europe/Milan</code> merely because Milan's population has grown
2941.3Schristos    to be somewhat greater than Rome's.
2951.1Schristos  </li>
2961.1Schristos  <li>
2971.3Schristos    If a name is changed, put its old spelling in the
2981.13Schristos    '<code>backward</code>' file as a link to the new spelling.
2991.3Schristos    This means old spellings will continue to work.
3001.9Schristos    Ordinarily a name change should occur only in the rare case when
3011.9Schristos    a location's consensus English-language spelling changes; for example,
3021.9Schristos    in 2008 <code>Asia/Calcutta</code> was renamed to <code>Asia/Kolkata</code>
3031.9Schristos    due to long-time widespread use of the new city name instead of the old.
3041.1Schristos  </li>
3051.1Schristos</ul>
3061.1Schristos
3071.1Schristos<p>
3081.7SchristosGuidelines have evolved with time, and names following old versions of
3091.8Schristosthese guidelines might not follow the current version. When guidelines
3101.7Schristoshave changed, old names continue to be supported. Guideline changes
3111.7Schristoshave included the following:
3121.1Schristos</p>
3131.1Schristos
3141.7Schristos<ul>
3151.7Schristos<li>
3161.7SchristosOlder versions of this package used a different naming scheme.
3171.1SchristosSee the file '<code>backward</code>' for most of these older names
3181.1Schristos(e.g., '<code>US/Eastern</code>' instead of '<code>America/New_York</code>').
3191.1SchristosThe other old-fashioned names still supported are
3201.3Schristos'<code>WET</code>', '<code>CET</code>', '<code>MET</code>', and
3211.3Schristos'<code>EET</code>' (see the file '<code>europe</code>').
3221.7Schristos</li>
3231.1Schristos
3241.7Schristos<li>
3251.1SchristosOlder versions of this package defined legacy names that are
3261.3Schristosincompatible with the first guideline of location names, but which are
3271.3Schristosstill supported.
3281.3SchristosThese legacy names are mostly defined in the file
3291.3Schristos'<code>etcetera</code>'.
3301.3SchristosAlso, the file '<code>backward</code>' defines the legacy names
3311.16Schristos'<code>Etc/GMT0</code>', '<code>Etc/GMT-0</code>', '<code>Etc/GMT+0</code>',
3321.3Schristos'<code>GMT0</code>', '<code>GMT-0</code>' and '<code>GMT+0</code>',
3331.3Schristosand the file '<code>northamerica</code>' defines the legacy names
3341.3Schristos'<code>EST5EDT</code>', '<code>CST6CDT</code>',
3351.3Schristos'<code>MST7MDT</code>', and '<code>PST8PDT</code>'.
3361.7Schristos</li>
3371.7Schristos
3381.7Schristos<li>
3391.8SchristosOlder versions of these guidelines said that
3401.7Schristosthere should typically be at least one name for each <a
3411.7Schristoshref="https://en.wikipedia.org/wiki/ISO_3166-1"><abbr
3421.7Schristostitle="International Organization for Standardization">ISO</abbr>
3431.7Schristos3166-1</a> officially assigned two-letter code for an inhabited
3441.7Schristoscountry or territory.
3451.7SchristosThis old guideline has been dropped, as it was not needed to handle
3461.7Schristostimestamps correctly and it increased maintenance burden.
3471.7Schristos</li>
3481.7Schristos</ul>
3491.7Schristos
3501.7Schristos<p>
3511.13SchristosThe file <code>zone1970.tab</code> lists geographical locations used
3521.7Schristosto name timezones.
3531.7SchristosIt is intended to be an exhaustive list of names for geographic
3541.7Schristosregions as described above; this is a subset of the timezones in the data.
3551.13SchristosAlthough a <code>zone1970.tab</code> location's
3561.7Schristos<a href="https://en.wikipedia.org/wiki/Longitude">longitude</a>
3571.7Schristoscorresponds to
3581.7Schristosits <a href="https://en.wikipedia.org/wiki/Local_mean_time">local mean
3591.7Schristostime (<abbr>LMT</abbr>)</a> offset with one hour for every 15&deg;
3601.7Schristoseast longitude, this relationship is not exact.
3611.13SchristosThe backward-compatibility file <code>zone.tab</code> is similar
3621.13Schristosbut conforms to the older-version guidelines related to <abbr>ISO</abbr> 3166-1;
3631.13Schristosit lists only one country code per entry and unlike <code>zone1970.tab</code>
3641.13Schristosit can list names defined in <code>backward</code>.
3651.1Schristos</p>
3661.1Schristos
3671.1Schristos<p>
3681.13SchristosThe database defines each timezone name to be a zone, or a link to a zone.
3691.13SchristosThe source file <code>backward</code> defines links for backward
3701.13Schristoscompatibility; it does not define zones.
3711.13SchristosAlthough <code>backward</code> was originally designed to be optional,
3721.13Schristosnowadays distributions typically use it
3731.13Schristosand no great weight should be attached to whether a link
3741.13Schristosis defined in <code>backward</code> or in some other file.
3751.13SchristosThe source file <code>etcetera</code> defines names that may be useful
3761.13Schristoson platforms that do not support POSIX-style <code>TZ</code> strings;
3771.13Schristosno other source file other than <code>backward</code>
3781.13Schristoscontains links to its zones.
3791.14SchristosOne of <code>etcetera</code>'s names is <code>Etc/UTC</code>,
3801.13Schristosused by functions like <code>gmtime</code> to obtain leap
3811.13Schristossecond information on platforms that support leap seconds.
3821.14SchristosAnother <code>etcetera</code> name, <code>GMT</code>,
3831.14Schristosis used by older code releases.
3841.1Schristos</p>
3851.3Schristos</section>
3861.1Schristos
3871.3Schristos<section>
3881.3Schristos  <h2 id="abbreviations">Time zone abbreviations</h2>
3891.1Schristos<p>
3901.1SchristosWhen this package is installed, it generates time zone abbreviations
3911.1Schristoslike '<code>EST</code>' to be compatible with human tradition and POSIX.
3921.3SchristosHere are the general guidelines used for choosing time zone abbreviations,
3931.1Schristosin decreasing order of importance:
3941.3Schristos</p>
3951.3Schristos
3961.1Schristos<ul>
3971.1Schristos  <li>
3981.3Schristos    Use three to six characters that are ASCII alphanumerics or
3991.3Schristos    '<code>+</code>' or '<code>-</code>'.
4001.3Schristos    Previous editions of this database also used characters like
4011.3Schristos    space and '<code>?</code>', but these characters have a
4021.3Schristos    special meaning to the
4031.3Schristos    <a href="https://en.wikipedia.org/wiki/Unix_shell">UNIX shell</a>
4041.3Schristos    and cause commands like
4051.8Schristos    '<code><a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set">set</a>
4061.8Schristos    `<a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html">date</a>`</code>'
4071.3Schristos    to have unexpected effects.
4081.3Schristos    Previous editions of this guideline required upper-case letters, but the
4091.3Schristos    Congressman who introduced
4101.3Schristos    <a href="https://en.wikipedia.org/wiki/Chamorro_Time_Zone">Chamorro
4111.3Schristos    Standard Time</a> preferred "ChST", so lower-case letters are now
4121.3Schristos    allowed.
4131.3Schristos    Also, POSIX from 2001 on relaxed the rule to allow '<code>-</code>',
4141.3Schristos    '<code>+</code>', and alphanumeric characters from the portable
4151.3Schristos    character set in the current locale.
4161.3Schristos    In practice ASCII alphanumerics and '<code>+</code>' and
4171.3Schristos    '<code>-</code>' are safe in all locales.
4181.3Schristos
4191.3Schristos    <p>
4201.3Schristos    In other words, in the C locale the POSIX extended regular
4211.3Schristos    expression <code>[-+[:alnum:]]{3,6}</code> should match the
4221.3Schristos    abbreviation.
4231.3Schristos    This guarantees that all abbreviations could have been specified by a
4241.3Schristos    POSIX <code>TZ</code> string.
4251.3Schristos    </p>
4261.3Schristos  </li>
4271.3Schristos  <li>
4281.3Schristos    Use abbreviations that are in common use among English-speakers,
4291.3Schristos    e.g., 'EST' for Eastern Standard Time in North America.
4301.3Schristos    We assume that applications translate them to other languages
4311.3Schristos    as part of the normal localization process; for example,
4321.3Schristos    a French application might translate 'EST' to 'HNE'.
4331.3Schristos
4341.3Schristos    <p>
4351.3Schristos    <small>These abbreviations (for standard/daylight/etc. time) are:
4361.3Schristos      ACST/ACDT Australian Central,
4371.3Schristos      AST/ADT/APT/AWT/ADDT Atlantic,
4381.3Schristos      AEST/AEDT Australian Eastern,
4391.3Schristos      AHST/AHDT Alaska-Hawaii,
4401.3Schristos      AKST/AKDT Alaska,
4411.3Schristos      AWST/AWDT Australian Western,
4421.3Schristos      BST/BDT Bering,
4431.3Schristos      CAT/CAST Central Africa,
4441.3Schristos      CET/CEST/CEMT Central European,
4451.3Schristos      ChST Chamorro,
4461.18Schristos      CST/CDT/CWT/CPT Central [North America],
4471.3Schristos      CST/CDT China,
4481.3Schristos      GMT/BST/IST/BDST Greenwich,
4491.3Schristos      EAT East Africa,
4501.18Schristos      EST/EDT/EWT/EPT Eastern [North America],
4511.3Schristos      EET/EEST Eastern European,
4521.6Schristos      GST/GDT Guam,
4531.5Schristos      HST/HDT/HWT/HPT Hawaii,
4541.9Schristos      HKT/HKST/HKWT Hong Kong,
4551.3Schristos      IST India,
4561.3Schristos      IST/GMT Irish,
4571.3Schristos      IST/IDT/IDDT Israel,
4581.3Schristos      JST/JDT Japan,
4591.3Schristos      KST/KDT Korea,
4601.3Schristos      MET/MEST Middle European (a backward-compatibility alias for
4611.3Schristos	Central European),
4621.3Schristos      MSK/MSD Moscow,
4631.18Schristos      MST/MDT/MWT/MPT Mountain,
4641.3Schristos      NST/NDT/NWT/NPT/NDDT Newfoundland,
4651.3Schristos      NST/NDT/NWT/NPT Nome,
4661.3Schristos      NZMT/NZST New Zealand through 1945,
4671.3Schristos      NZST/NZDT New Zealand 1946&ndash;present,
4681.3Schristos      PKT/PKST Pakistan,
4691.18Schristos      PST/PDT/PWT/PPT Pacific,
4701.4Schristos      PST/PDT Philippine,
4711.3Schristos      SAST South Africa,
4721.3Schristos      SST Samoa,
4731.14Schristos      UTC Universal,
4741.3Schristos      WAT/WAST West Africa,
4751.3Schristos      WET/WEST/WEMT Western European,
4761.3Schristos      WIB Waktu Indonesia Barat,
4771.3Schristos      WIT Waktu Indonesia Timur,
4781.3Schristos      WITA Waktu Indonesia Tengah,
4791.3Schristos      YST/YDT/YWT/YPT/YDDT Yukon</small>.
4801.3Schristos    </p>
4811.3Schristos  </li>
4821.3Schristos  <li>
4831.3Schristos    <p>
4841.3Schristos    For times taken from a city's longitude, use the
4851.3Schristos    traditional <var>x</var>MT notation.
4861.3Schristos    The only abbreviation like this in current use is '<abbr>GMT</abbr>'.
4871.3Schristos    The others are for timestamps before 1960,
4881.3Schristos    except that Monrovia Mean Time persisted until 1972.
4891.3Schristos    Typically, numeric abbreviations (e.g., '<code>-</code>004430' for
4901.3Schristos    MMT) would cause trouble here, as the numeric strings would exceed
4911.3Schristos    the POSIX length limit.
4921.3Schristos    </p>
4931.3Schristos
4941.3Schristos    <p>
4951.3Schristos    <small>These abbreviations are:
4961.12Schristos      AMT Asunción, Athens;
4971.18Schristos      BMT Baghdad, Bangkok, Batavia, Bermuda, Bern, Bogotá,
4981.11Schristos        Brussels, Bucharest;
4991.12Schristos      CMT Calamarca, Caracas, Chisinau, Colón, Córdoba;
5001.3Schristos      DMT Dublin/Dunsink;
5011.3Schristos      EMT Easter;
5021.3Schristos      FFMT Fort-de-France;
5031.3Schristos      FMT Funchal;
5041.3Schristos      GMT Greenwich;
5051.3Schristos      HMT Havana, Helsinki, Horta, Howrah;
5061.3Schristos      IMT Irkutsk, Istanbul;
5071.3Schristos      JMT Jerusalem;
5081.14Schristos      KMT Kaunas, Kyiv, Kingston;
5091.18Schristos      LMT Lima, Lisbon, local;
5101.3Schristos      MMT Macassar, Madras, Malé, Managua, Minsk, Monrovia, Montevideo,
5111.3Schristos	Moratuwa, Moscow;
5121.3Schristos      PLMT Phù Liễn;
5131.3Schristos      PMT Paramaribo, Paris, Perm, Pontianak, Prague;
5141.3Schristos      PMMT Port Moresby;
5151.18Schristos      PPMT Port-au-Prince;
5161.3Schristos      QMT Quito;
5171.3Schristos      RMT Rangoon, Riga, Rome;
5181.3Schristos      SDMT Santo Domingo;
5191.3Schristos      SJMT San José;
5201.3Schristos      SMT Santiago, Simferopol, Singapore, Stanley;
5211.3Schristos      TBMT Tbilisi;
5221.3Schristos      TMT Tallinn, Tehran;
5231.18Schristos      WMT Warsaw.</small>
5241.3Schristos    </p>
5251.3Schristos
5261.3Schristos    <p>
5271.3Schristos    <small>A few abbreviations also follow the pattern that
5281.4Schristos    <abbr>GMT</abbr>/<abbr>BST</abbr> established for time in the UK.
5291.3Schristos    They are:
5301.11Schristos      BMT/BST for Bermuda 1890&ndash;1930,
5311.3Schristos      CMT/BST for Calamarca Mean Time and Bolivian Summer Time
5321.3Schristos	1890&ndash;1932,
5331.3Schristos      DMT/IST for Dublin/Dunsink Mean Time and Irish Summer Time
5341.3Schristos	1880&ndash;1916,
5351.3Schristos      MMT/MST/MDST for Moscow 1880&ndash;1919, and
5361.3Schristos      RMT/LST for Riga Mean Time and Latvian Summer time 1880&ndash;1926.
5371.12Schristos    </small>
5381.3Schristos    </p>
5391.3Schristos  </li>
5401.3Schristos  <li>
5411.3Schristos    Use '<abbr>LMT</abbr>' for local mean time of locations before the
5421.3Schristos    introduction of standard time; see "<a href="#scope">Scope of the
5431.3Schristos    <code><abbr>tz</abbr></code> database</a>".
5441.3Schristos  </li>
5451.3Schristos  <li>
5461.3Schristos    If there is no common English abbreviation, use numeric offsets like
5471.4Schristos    <code>-</code>05 and <code>+</code>0530 that are generated
5481.3Schristos    by <code>zic</code>'s <code>%z</code> notation.
5491.3Schristos  </li>
5501.3Schristos  <li>
5511.3Schristos    Use current abbreviations for older timestamps to avoid confusion.
5521.3Schristos    For example, in 1910 a common English abbreviation for time
5531.3Schristos    in central Europe was 'MEZ' (short for both "Middle European
5541.3Schristos    Zone" and for "Mitteleuropäische Zeit" in German).
5551.3Schristos    Nowadays 'CET' ("Central European Time") is more common in
5561.3Schristos    English, and the database uses 'CET' even for circa-1910
5571.3Schristos    timestamps as this is less confusing for modern users and avoids
5581.3Schristos    the need for determining when 'CET' supplanted 'MEZ' in common
5591.3Schristos    usage.
5601.3Schristos  </li>
5611.3Schristos  <li>
5621.4Schristos    Use a consistent style in a timezone's history.
5631.4Schristos    For example, if a history tends to use numeric
5641.3Schristos    abbreviations and a particular entry could go either way, use a
5651.3Schristos    numeric abbreviation.
5661.3Schristos  </li>
5671.3Schristos  <li>
5681.3Schristos    Use
5691.3Schristos    <a href="https://en.wikipedia.org/wiki/Universal_Time">Universal Time</a>
5701.3Schristos    (<abbr>UT</abbr>) (with time zone abbreviation '<code>-</code>00') for
5711.3Schristos    locations while uninhabited.
5721.3Schristos    The leading '<code>-</code>' is a flag that the <abbr>UT</abbr> offset is in
5731.3Schristos    some sense undefined; this notation is derived
5741.15Schristos    from <a href="https://datatracker.ietf.org/doc/html/rfc3339">Internet
5751.4Schristos    <abbr title="Request For Comments">RFC</abbr> 3339</a>.
5761.1Schristos  </li>
5771.1Schristos</ul>
5781.3Schristos
5791.1Schristos<p>
5801.1SchristosApplication writers should note that these abbreviations are ambiguous
5811.2Schristosin practice: e.g., 'CST' means one thing in China and something else
5821.2Schristosin North America, and 'IST' can refer to time in India, Ireland or
5831.3SchristosIsrael.
5841.3SchristosTo avoid ambiguity, use numeric <abbr>UT</abbr> offsets like
5851.2Schristos'<code>-</code>0600' instead of time zone abbreviations like 'CST'.
5861.1Schristos</p>
5871.3Schristos</section>
5881.1Schristos
5891.3Schristos<section>
5901.3Schristos  <h2 id="accuracy">Accuracy of the <code><abbr>tz</abbr></code> database</h2>
5911.1Schristos<p>
5921.3SchristosThe <code><abbr>tz</abbr></code> database is not authoritative, and it
5931.3Schristossurely has errors.
5941.2SchristosCorrections are welcome and encouraged; see the file <code>CONTRIBUTING</code>.
5951.1SchristosUsers requiring authoritative data should consult national standards
5961.1Schristosbodies and the references cited in the database's comments.
5971.1Schristos</p>
5981.1Schristos
5991.1Schristos<p>
6001.3SchristosErrors in the <code><abbr>tz</abbr></code> database arise from many sources:
6011.1Schristos</p>
6021.3Schristos
6031.1Schristos<ul>
6041.1Schristos  <li>
6051.3Schristos    The <code><abbr>tz</abbr></code> database predicts future
6061.3Schristos    timestamps, and current predictions
6071.3Schristos    will be incorrect after future governments change the rules.
6081.3Schristos    For example, if today someone schedules a meeting for 13:00 next
6091.3Schristos    October 1, Casablanca time, and tomorrow Morocco changes its
6101.3Schristos    daylight saving rules, software can mess up after the rule change
6111.3Schristos    if it blithely relies on conversions made before the change.
6121.3Schristos  </li>
6131.3Schristos  <li>
6141.3Schristos    The pre-1970 entries in this database cover only a tiny sliver of how
6151.3Schristos    clocks actually behaved; the vast majority of the necessary
6161.3Schristos    information was lost or never recorded.
6171.4Schristos    Thousands more timezones would be needed if
6181.3Schristos    the <code><abbr>tz</abbr></code> database's scope were extended to
6191.3Schristos    cover even just the known or guessed history of standard time; for
6201.3Schristos    example, the current single entry for France would need to split
6211.3Schristos    into dozens of entries, perhaps hundreds.
6221.3Schristos    And in most of the world even this approach would be misleading
6231.3Schristos    due to widespread disagreement or indifference about what times
6241.3Schristos    should be observed.
6251.3Schristos    In her 2015 book
6261.3Schristos    <cite><a
6271.15Schristos    href="https://www.hup.harvard.edu/catalog.php?isbn=9780674286146">The
6281.3Schristos    Global Transformation of Time, 1870&ndash;1950</a></cite>,
6291.3Schristos    Vanessa Ogle writes
6301.3Schristos    "Outside of Europe and North America there was no system of time
6311.3Schristos    zones at all, often not even a stable landscape of mean times,
6321.3Schristos    prior to the middle decades of the twentieth century".
6331.3Schristos    See: Timothy Shenk, <a
6341.3Schristoshref="https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle">Booked:
6351.3Schristos      A Global History of Time</a>. <cite>Dissent</cite> 2015-12-17.
6361.3Schristos  </li>
6371.3Schristos  <li>
6381.3Schristos    Most of the pre-1970 data entries come from unreliable sources, often
6391.3Schristos    astrology books that lack citations and whose compilers evidently
6401.3Schristos    invented entries when the true facts were unknown, without
6411.3Schristos    reporting which entries were known and which were invented.
6421.3Schristos    These books often contradict each other or give implausible entries,
6431.3Schristos    and on the rare occasions when they are checked they are
6441.3Schristos    typically found to be incorrect.
6451.3Schristos  </li>
6461.3Schristos  <li>
6471.3Schristos    For the UK the <code><abbr>tz</abbr></code> database relies on
6481.3Schristos    years of first-class work done by
6491.3Schristos    Joseph Myers and others; see
6501.3Schristos    "<a href="https://www.polyomino.org.uk/british-time/">History of
6511.3Schristos    legal time in Britain</a>".
6521.3Schristos    Other countries are not done nearly as well.
6531.3Schristos  </li>
6541.3Schristos  <li>
6551.3Schristos    Sometimes, different people in the same city maintain clocks
6561.3Schristos    that differ significantly.
6571.3Schristos    Historically, railway time was used by railroad companies (which
6581.3Schristos    did not always
6591.3Schristos    agree with each other), church-clock time was used for birth
6601.3Schristos    certificates, etc.
6611.3Schristos    More recently, competing political groups might disagree about
6621.3Schristos    clock settings. Often this is merely common practice, but
6631.3Schristos    sometimes it is set by law.
6641.3Schristos    For example, from 1891 to 1911 the <abbr>UT</abbr> offset in France
6651.3Schristos    was legally <abbr>UT</abbr> +00:09:21 outside train stations and
6661.3Schristos    <abbr>UT</abbr> +00:04:21 inside. Other examples include
6671.3Schristos    Chillicothe in 1920, Palm Springs in 1946/7, and Jerusalem and
6681.3Schristos    Ürümqi to this day.
6691.3Schristos  </li>
6701.3Schristos  <li>
6711.3Schristos    Although a named location in the <code><abbr>tz</abbr></code>
6721.3Schristos    database stands for the containing region, its pre-1970 data
6731.3Schristos    entries are often accurate for only a small subset of that region.
6741.3Schristos    For example, <code>Europe/London</code> stands for the United
6751.3Schristos    Kingdom, but its pre-1847 times are valid only for locations that
6761.3Schristos    have London's exact meridian, and its 1847 transition
6771.3Schristos    to <abbr>GMT</abbr> is known to be valid only for the L&amp;NW and
6781.3Schristos    the Caledonian railways.
6791.3Schristos  </li>
6801.3Schristos  <li>
6811.3Schristos    The <code><abbr>tz</abbr></code> database does not record the
6821.4Schristos    earliest time for which a timezone's
6831.3Schristos    data entries are thereafter valid for every location in the region.
6841.3Schristos    For example, <code>Europe/London</code> is valid for all locations
6851.3Schristos    in its region after <abbr>GMT</abbr> was made the standard time,
6861.3Schristos    but the date of standardization (1880-08-02) is not in the
6871.3Schristos    <code><abbr>tz</abbr></code> database, other than in commentary.
6881.4Schristos    For many timezones the earliest time of
6891.3Schristos    validity is unknown.
6901.3Schristos  </li>
6911.3Schristos  <li>
6921.3Schristos    The <code><abbr>tz</abbr></code> database does not record a
6931.3Schristos    region's boundaries, and in many cases the boundaries are not known.
6941.4Schristos    For example, the timezone
6951.3Schristos    <code>America/Kentucky/Louisville</code> represents a region
6961.3Schristos    around the city of Louisville, the boundaries of which are
6971.3Schristos    unclear.
6981.3Schristos  </li>
6991.3Schristos  <li>
7001.3Schristos    Changes that are modeled as instantaneous transitions in the
7011.3Schristos    <code><abbr>tz</abbr></code>
7021.3Schristos    database were often spread out over hours, days, or even decades.
7031.3Schristos  </li>
7041.3Schristos  <li>
7051.3Schristos    Even if the time is specified by law, locations sometimes
7061.3Schristos    deliberately flout the law.
7071.3Schristos  </li>
7081.3Schristos  <li>
7091.3Schristos    Early timekeeping practices, even assuming perfect clocks, were
7101.3Schristos    often not specified to the accuracy that the
7111.3Schristos    <code><abbr>tz</abbr></code> database requires.
7121.3Schristos  </li>
7131.3Schristos  <li>
7141.10Schristos    The <code><abbr>tz</abbr></code> database cannot represent stopped clocks.
7151.10Schristos    However, on 1911-03-11 at 00:00, some public-facing French clocks
7161.10Schristos    were changed by stopping them for a few minutes to effect a transition.
7171.10Schristos    The <code><abbr>tz</abbr></code> database models this via a
7181.10Schristos    backward transition; the relevant French legislation does not
7191.10Schristos    specify exactly how the transition was to occur.
7201.10Schristos  </li>
7211.10Schristos  <li>
7221.3Schristos    Sometimes historical timekeeping was specified more precisely
7231.3Schristos    than what the <code><abbr>tz</abbr></code> code can handle.
7241.12Schristos    For example, from 1880 to 1916 clocks in Ireland observed Dublin Mean
7251.3Schristos    Time (estimated to be <abbr>UT</abbr>
7261.14Schristos    &minus;00:25:21.1); although the <code><abbr>tz</abbr></code>
7271.14Schristos    source data can represent the .1 second, TZif files and the code cannot.
7281.3Schristos    In practice these old specifications were rarely if ever
7291.3Schristos    implemented to subsecond precision.
7301.3Schristos  </li>
7311.3Schristos  <li>
7321.3Schristos    Even when all the timestamp transitions recorded by the
7331.3Schristos    <code><abbr>tz</abbr></code> database are correct, the
7341.3Schristos    <code><abbr>tz</abbr></code> rules that generate them may not
7351.3Schristos    faithfully reflect the historical rules.
7361.3Schristos    For example, from 1922 until World War II the UK moved clocks
7371.3Schristos    forward the day following the third Saturday in April unless that
7381.3Schristos    was Easter, in which case it moved clocks forward the previous
7391.3Schristos    Sunday.
7401.3Schristos    Because the <code><abbr>tz</abbr></code> database has no
7411.3Schristos    way to specify Easter, these exceptional years are entered as
7421.3Schristos    separate <code><abbr>tz</abbr> Rule</code> lines, even though the
7431.3Schristos    legal rules did not change.
7441.4Schristos    When transitions are known but the historical rules behind them are not,
7451.4Schristos    the database contains <code>Zone</code> and <code>Rule</code>
7461.4Schristos    entries that are intended to represent only the generated
7471.4Schristos    transitions, not any underlying historical rules; however, this
7481.4Schristos    intent is recorded at best only in commentary.
7491.3Schristos  </li>
7501.3Schristos  <li>
7511.4Schristos    The <code><abbr>tz</abbr></code> database models time
7521.3Schristos    using the <a
7531.3Schristos    href="https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar">proleptic
7541.4Schristos    Gregorian calendar</a> with days containing 24 equal-length hours
7551.4Schristos    numbered 00 through 23, except when clock transitions occur.
7561.4Schristos    Pre-standard time is modeled as local mean time.
7571.4Schristos    However, historically many people used other calendars and other timescales.
7581.3Schristos    For example, the Roman Empire used
7591.3Schristos    the <a href="https://en.wikipedia.org/wiki/Julian_calendar">Julian
7601.3Schristos    calendar</a>,
7611.3Schristos    and <a href="https://en.wikipedia.org/wiki/Roman_timekeeping">Roman
7621.3Schristos    timekeeping</a> had twelve varying-length daytime hours with a
7631.3Schristos    non-hour-based system at night.
7641.4Schristos    And even today, some local practices diverge from the Gregorian
7651.4Schristos    calendar with 24-hour days. These divergences range from
7661.4Schristos    relatively minor, such as Japanese bars giving times like "24:30" for the
7671.4Schristos    wee hours of the morning, to more-significant differences such as <a
7681.4Schristos    href="https://www.pri.org/stories/2015-01-30/if-you-have-meeting-ethiopia-you-better-double-check-time">the
7691.4Schristos    east African practice of starting the day at dawn</a>, renumbering
7701.4Schristos    the Western 06:00 to be 12:00. These practices are largely outside
7711.4Schristos    the scope of the <code><abbr>tz</abbr></code> code and data, which
7721.4Schristos    provide only limited support for date and time localization
7731.12Schristos    such as that required by POSIX.
7741.12Schristos    If <abbr>DST</abbr> is not used a different time zone
7751.4Schristos    can often do the trick; for example, in Kenya a <code>TZ</code> setting
7761.4Schristos    like <code>&lt;-03&gt;3</code> or <code>America/Cayenne</code> starts
7771.4Schristos    the day six hours later than <code>Africa/Nairobi</code> does.
7781.3Schristos  </li>
7791.3Schristos  <li>
7801.3Schristos    Early clocks were less reliable, and data entries do not represent
7811.3Schristos    clock error.
7821.3Schristos  </li>
7831.3Schristos  <li>
7841.3Schristos    The <code><abbr>tz</abbr></code> database assumes Universal Time
7851.3Schristos    (<abbr>UT</abbr>) as an origin, even though <abbr>UT</abbr> is not
7861.3Schristos    standardized for older timestamps.
7871.3Schristos    In the <code><abbr>tz</abbr></code> database commentary,
7881.3Schristos    <abbr>UT</abbr> denotes a family of time standards that includes
7891.3Schristos    Coordinated Universal Time (<abbr>UTC</abbr>) along with other
7901.3Schristos    variants such as <abbr>UT1</abbr> and <abbr>GMT</abbr>,
7911.3Schristos    with days starting at midnight.
7921.3Schristos    Although <abbr>UT</abbr> equals <abbr>UTC</abbr> for modern
7931.3Schristos    timestamps, <abbr>UTC</abbr> was not defined until 1960, so
7941.18Schristos    commentary uses the more general abbreviation <abbr>UT</abbr> for
7951.3Schristos    timestamps that might predate 1960.
7961.3Schristos    Since <abbr>UT</abbr>, <abbr>UT1</abbr>, etc. disagree slightly,
7971.3Schristos    and since pre-1972 <abbr>UTC</abbr> seconds varied in length,
7981.3Schristos    interpretation of older timestamps can be problematic when
7991.3Schristos    subsecond accuracy is needed.
8001.3Schristos  </li>
8011.3Schristos  <li>
8021.3Schristos    Civil time was not based on atomic time before 1972, and we do not
8031.3Schristos    know the history of
8041.3Schristos    <a href="https://en.wikipedia.org/wiki/Earth's_rotation">earth's
8051.3Schristos    rotation</a> accurately enough to map <a
8061.3Schristos    href="https://en.wikipedia.org/wiki/International_System_of_Units"><abbr
8071.3Schristos    title="International System of Units">SI</abbr></a> seconds to
8081.3Schristos    historical <a href="https://en.wikipedia.org/wiki/Solar_time">solar time</a>
8091.3Schristos    to more than about one-hour accuracy.
8101.3Schristos    See: Stephenson FR, Morrison LV, Hohenkerk CY.
8111.4Schristos    <a href="https://dx.doi.org/10.1098/rspa.2016.0404">Measurement of
8121.3Schristos    the Earth's rotation: 720 BC to AD 2015</a>.
8131.15Schristos    <cite>Proc Royal Soc A</cite>. 2016;472:20160404.
8141.3Schristos    Also see: Espenak F. <a
8151.3Schristos    href="https://eclipse.gsfc.nasa.gov/SEhelp/uncertainty2004.html">Uncertainty
8161.3Schristos    in Delta T (ΔT)</a>.
8171.3Schristos  </li>
8181.3Schristos  <li>
8191.3Schristos    The relationship between POSIX time (that is, <abbr>UTC</abbr> but
8201.3Schristos    ignoring <a href="https://en.wikipedia.org/wiki/Leap_second">leap
8211.18Schristos    seconds</a>) and <abbr>UTC</abbr> is not agreed upon.
8221.18Schristos    This affects time stamps during the leap second era (1972&ndash;2035).
8231.3Schristos    Although the POSIX
8241.3Schristos    clock officially stops during an inserted leap second, at least one
8251.3Schristos    proposed standard has it jumping back a second instead; and in
8261.3Schristos    practice POSIX clocks more typically either progress glacially during
8271.3Schristos    a leap second, or are slightly slowed while near a leap second.
8281.3Schristos  </li>
8291.3Schristos  <li>
8301.3Schristos    The <code><abbr>tz</abbr></code> database does not represent how
8311.3Schristos    uncertain its information is.
8321.3Schristos    Ideally it would contain information about when data entries are
8331.3Schristos    incomplete or dicey.
8341.3Schristos    Partial temporal knowledge is a field of active research, though,
8351.3Schristos    and it is not clear how to apply it here.
8361.1Schristos  </li>
8371.1Schristos</ul>
8381.1Schristos
8391.1Schristos<p>
8401.3SchristosIn short, many, perhaps most, of the <code><abbr>tz</abbr></code>
8411.3Schristosdatabase's pre-1970 and future timestamps are either wrong or
8421.3Schristosmisleading.
8431.3SchristosAny attempt to pass the
8441.3Schristos<code><abbr>tz</abbr></code> database off as the definition of time
8451.3Schristosshould be unacceptable to anybody who cares about the facts.
8461.3SchristosIn particular, the <code><abbr>tz</abbr></code> database's
8471.3Schristos<abbr>LMT</abbr> offsets should not be considered meaningful, and
8481.4Schristosshould not prompt creation of timezones
8491.3Schristosmerely because two locations
8501.3Schristosdiffer in <abbr>LMT</abbr> or transitioned to standard time at
8511.3Schristosdifferent dates.
8521.3Schristos</p>
8531.3Schristos</section>
8541.3Schristos
8551.3Schristos<section>
8561.3Schristos  <h2 id="functions">Time and date functions</h2>
8571.3Schristos<p>
8581.3SchristosThe <code><abbr>tz</abbr></code> code contains time and date functions
8591.3Schristosthat are upwards compatible with those of POSIX.
8601.3SchristosCode compatible with this package is already
8611.3Schristos<a href="tz-link.html#tzdb">part of many platforms</a>, where the
8621.3Schristosprimary use of this package is to update obsolete time-related files.
8631.3SchristosTo do this, you may need to compile the time zone compiler
8641.3Schristos'<code>zic</code>' supplied with this package instead of using the
8651.3Schristossystem '<code>zic</code>', since the format of <code>zic</code>'s
8661.3Schristosinput is occasionally extended, and a platform may still be shipping
8671.3Schristosan older <code>zic</code>.
8681.1Schristos</p>
8691.1Schristos
8701.3Schristos<h3 id="POSIX">POSIX properties and limitations</h3>
8711.1Schristos<ul>
8721.1Schristos  <li>
8731.1Schristos    <p>
8741.3Schristos    In POSIX, time display in a process is controlled by the
8751.3Schristos    environment variable <code>TZ</code>.
8761.3Schristos    Unfortunately, the POSIX
8771.3Schristos    <code>TZ</code> string takes a form that is hard to describe and
8781.3Schristos    is error-prone in practice.
8791.3Schristos    Also, POSIX <code>TZ</code> strings cannot deal with daylight
8801.3Schristos    saving time rules not based on the Gregorian calendar (as in
8811.18Schristos    Morocco), or with situations where more than two time zone
8821.3Schristos    abbreviations or <abbr>UT</abbr> offsets are used in an area.
8831.1Schristos    </p>
8841.3Schristos
8851.1Schristos    <p>
8861.3Schristos    The POSIX <code>TZ</code> string takes the following form:
8871.1Schristos    </p>
8881.3Schristos
8891.1Schristos    <p>
8901.3Schristos    <var>stdoffset</var>[<var>dst</var>[<var>offset</var>][<code>,</code><var>date</var>[<code>/</code><var>time</var>]<code>,</code><var>date</var>[<code>/</code><var>time</var>]]]
8911.1Schristos    </p>
8921.3Schristos
8931.1Schristos    <p>
8941.3Schristos    where:
8951.3Schristos    </p>
8961.3Schristos
8971.1Schristos    <dl>
8981.1Schristos      <dt><var>std</var> and <var>dst</var></dt><dd>
8991.3Schristos	are 3 or more characters specifying the standard
9001.4Schristos	and daylight saving time (<abbr>DST</abbr>) zone abbreviations.
9011.3Schristos	Starting with POSIX.1-2001, <var>std</var> and <var>dst</var>
9021.3Schristos	may also be in a quoted form like '<code>&lt;+09&gt;</code>';
9031.3Schristos	this allows "<code>+</code>" and "<code>-</code>" in the names.
9041.1Schristos      </dd>
9051.1Schristos      <dt><var>offset</var></dt><dd>
9061.3Schristos	is of the form
9071.3Schristos	'<code>[&plusmn;]<var>hh</var>:[<var>mm</var>[:<var>ss</var>]]</code>'
9081.3Schristos	and specifies the offset west of <abbr>UT</abbr>.
9091.3Schristos	'<var>hh</var>' may be a single digit;
9101.3Schristos	0&le;<var>hh</var>&le;24.
9111.3Schristos	The default <abbr>DST</abbr> offset is one hour ahead of
9121.3Schristos	standard time.
9131.1Schristos      </dd>
9141.1Schristos      <dt><var>date</var>[<code>/</code><var>time</var>]<code>,</code><var>date</var>[<code>/</code><var>time</var>]</dt><dd>
9151.3Schristos	specifies the beginning and end of <abbr>DST</abbr>.
9161.3Schristos	If this is absent, the system supplies its own ruleset
9171.18Schristos	for <abbr>DST</abbr>, typically	current <abbr>US</abbr>
9181.18Schristos	<abbr>DST</abbr> rules.
9191.1Schristos      </dd>
9201.1Schristos      <dt><var>time</var></dt><dd>
9211.3Schristos	takes the form
9221.3Schristos	'<var>hh</var><code>:</code>[<var>mm</var>[<code>:</code><var>ss</var>]]'
9231.3Schristos	and defaults to 02:00.
9241.3Schristos	This is the same format as the offset, except that a
9251.3Schristos	leading '<code>+</code>' or '<code>-</code>' is not allowed.
9261.1Schristos      </dd>
9271.1Schristos      <dt><var>date</var></dt><dd>
9281.3Schristos	takes one of the following forms:
9291.1Schristos	<dl>
9301.1Schristos	  <dt>J<var>n</var> (1&le;<var>n</var>&le;365)</dt><dd>
9311.3Schristos	    origin-1 day number not counting February 29
9321.3Schristos	  </dd>
9331.1Schristos	  <dt><var>n</var> (0&le;<var>n</var>&le;365)</dt><dd>
9341.3Schristos	    origin-0 day number counting February 29 if present
9351.3Schristos	  </dd>
9361.3Schristos	  <dt><code>M</code><var>m</var><code>.</code><var>n</var><code>.</code><var>d</var>
9371.3Schristos	    (0[Sunday]&le;<var>d</var>&le;6[Saturday], 1&le;<var>n</var>&le;5,
9381.3Schristos	    1&le;<var>m</var>&le;12)</dt><dd>
9391.3Schristos	    for the <var>d</var>th day of week <var>n</var> of
9401.3Schristos	    month <var>m</var> of the year, where week 1 is the first
9411.3Schristos	    week in which day <var>d</var> appears, and
9421.3Schristos	    '<code>5</code>' stands for the last week in which
9431.3Schristos	    day <var>d</var> appears (which may be either the 4th or
9441.3Schristos	    5th week).
9451.3Schristos	    Typically, this is the only useful form; the <var>n</var>
9461.3Schristos	    and <code>J</code><var>n</var> forms are rarely used.
9471.1Schristos	  </dd>
9481.3Schristos	</dl>
9491.3Schristos      </dd>
9501.3Schristos    </dl>
9511.3Schristos
9521.3Schristos    <p>
9531.3Schristos    Here is an example POSIX <code>TZ</code> string for New
9541.3Schristos    Zealand after 2007.
9551.3Schristos    It says that standard time (<abbr>NZST</abbr>) is 12 hours ahead
9561.3Schristos    of <abbr>UT</abbr>, and that daylight saving time
9571.3Schristos    (<abbr>NZDT</abbr>) is observed from September's last Sunday at
9581.3Schristos    02:00 until April's first Sunday at 03:00:
9591.3Schristos    </p>
9601.3Schristos
9611.3Schristos    <pre><code>TZ='NZST-12NZDT,M9.5.0,M4.1.0/3'</code></pre>
9621.3Schristos
9631.3Schristos    <p>
9641.3Schristos    This POSIX <code>TZ</code> string is hard to remember, and
9651.3Schristos    mishandles some timestamps before 2008.
9661.3Schristos    With this package you can use this instead:
9671.3Schristos    </p>
9681.3Schristos
9691.3Schristos    <pre><code>TZ='Pacific/Auckland'</code></pre>
9701.3Schristos  </li>
9711.3Schristos  <li>
9721.4Schristos    POSIX does not define the <abbr>DST</abbr> transitions
9731.4Schristos    for <code>TZ</code> values like
9741.3Schristos    "<code>EST5EDT</code>".
9751.4Schristos    Traditionally the current <abbr>US</abbr> <abbr>DST</abbr> rules
9761.4Schristos    were used to interpret such values, but this meant that the
9771.4Schristos    <abbr>US</abbr> <abbr>DST</abbr> rules were compiled into each
9781.18Schristos    time conversion package, and when
9791.4Schristos    <abbr>US</abbr> time conversion rules changed (as in the United
9801.18Schristos    States in 1987 and again in 2007), all packages that
9811.18Schristos    interpreted <code>TZ</code> values had to be updated
9821.18Schristos    to ensure proper results.
9831.3Schristos  </li>
9841.3Schristos  <li>
9851.3Schristos    The <code>TZ</code> environment variable is process-global, which
9861.3Schristos    makes it hard to write efficient, thread-safe applications that
9871.4Schristos    need access to multiple timezones.
9881.3Schristos  </li>
9891.3Schristos  <li>
9901.3Schristos    In POSIX, there is no tamper-proof way for a process to learn the
9911.8Schristos    system's best idea of local (wall clock) time.
9921.4Schristos    This is important for applications that an administrator wants
9931.3Schristos    used only at certain times &ndash; without regard to whether the
9941.3Schristos    user has fiddled the
9951.3Schristos    <code>TZ</code> environment variable.
9961.3Schristos    While an administrator can "do everything in <abbr>UT</abbr>" to
9971.3Schristos    get around the problem, doing so is inconvenient and precludes
9981.4Schristos    handling daylight saving time shifts &ndash; as might be required to
9991.4Schristos    limit phone calls to off-peak hours.
10001.3Schristos  </li>
10011.3Schristos  <li>
10021.3Schristos    POSIX provides no convenient and efficient way to determine
10031.3Schristos    the <abbr>UT</abbr> offset and time zone abbreviation of arbitrary
10041.4Schristos    timestamps, particularly for timezones
10051.3Schristos    that do not fit into the POSIX model.
10061.3Schristos  </li>
10071.3Schristos  <li>
10081.9Schristos    POSIX requires that <code>time_t</code> clock counts exclude leap
10091.9Schristos    seconds.
10101.3Schristos  </li>
10111.3Schristos  <li>
10121.3Schristos    The <code><abbr>tz</abbr></code> code attempts to support all the
10131.3Schristos    <code>time_t</code> implementations allowed by POSIX.
10141.3Schristos    The <code>time_t</code> type represents a nonnegative count of seconds
10151.3Schristos    since 1970-01-01 00:00:00 <abbr>UTC</abbr>, ignoring leap seconds.
10161.3Schristos    In practice, <code>time_t</code> is usually a signed 64- or 32-bit
10171.3Schristos    integer; 32-bit signed <code>time_t</code> values stop working after
10181.3Schristos    2038-01-19 03:14:07 <abbr>UTC</abbr>, so new implementations these
10191.3Schristos    days typically use a signed 64-bit integer.
10201.3Schristos    Unsigned 32-bit integers are used on one or two platforms, and 36-bit
10211.3Schristos    and 40-bit integers are also used occasionally.
10221.3Schristos    Although earlier POSIX versions allowed <code>time_t</code> to be a
10231.4Schristos    floating-point type, this was not supported by any practical system,
10241.3Schristos    and POSIX.1-2013 and the <code><abbr>tz</abbr></code> code both
10251.3Schristos    require <code>time_t</code> to be an integer type.
10261.1Schristos  </li>
10271.1Schristos</ul>
10281.3Schristos
10291.3Schristos<h3 id="POSIX-extensions">Extensions to POSIX in the
10301.3Schristos<code><abbr>tz</abbr></code> code</h3>
10311.1Schristos<ul>
10321.1Schristos  <li>
10331.1Schristos    <p>
10341.3Schristos    The <code>TZ</code> environment variable is used in generating
10351.4Schristos    the name of a file from which time-related information is read
10361.3Schristos    (or is interpreted à la POSIX); <code>TZ</code> is no longer
10371.4Schristos    constrained to be a string containing abbreviations
10381.4Schristos    and numeric data as described <a href="#POSIX">above</a>.
10391.4Schristos    The file's format is <dfn><abbr>TZif</abbr></dfn>,
10401.7Schristos    a timezone information format that contains binary data; see
10411.15Schristos    <a href="https://datatracker.ietf.org/doc/html/8536">Internet
10421.7Schristos    <abbr>RFC</abbr> 8536</a>.
10431.3Schristos    The daylight saving time rules to be used for a
10441.4Schristos    particular timezone are encoded in the
10451.4Schristos    <abbr>TZif</abbr> file; the format of the file allows <abbr>US</abbr>,
10461.4Schristos    Australian, and other rules to be encoded, and
10471.3Schristos    allows for situations where more than two time zone
10481.3Schristos    abbreviations are used.
10491.1Schristos    </p>
10501.1Schristos    <p>
10511.3Schristos    It was recognized that allowing the <code>TZ</code> environment
10521.3Schristos    variable to take on values such as '<code>America/New_York</code>'
10531.3Schristos    might cause "old" programs (that expect <code>TZ</code> to have a
10541.3Schristos    certain form) to operate incorrectly; consideration was given to using
10551.3Schristos    some other environment variable (for example, <code>TIMEZONE</code>)
10561.4Schristos    to hold the string used to generate the <abbr>TZif</abbr> file's name.
10571.3Schristos    In the end, however, it was decided to continue using
10581.3Schristos    <code>TZ</code>: it is widely used for time zone purposes;
10591.3Schristos    separately maintaining both <code>TZ</code>
10601.3Schristos    and <code>TIMEZONE</code> seemed a nuisance; and systems where
10611.3Schristos    "new" forms of <code>TZ</code> might cause problems can simply
10621.4Schristos    use legacy <code>TZ</code> values such as "<code>EST5EDT</code>" which
10631.4Schristos    can be used by "new" programs as well as by "old" programs that
10641.4Schristos    assume pre-POSIX <code>TZ</code> values.
10651.1Schristos    </p>
10661.3Schristos  </li>
10671.3Schristos  <li>
10681.3Schristos    The code supports platforms with a <abbr>UT</abbr> offset member
10691.15Schristos    in <code>struct tm</code>, e.g., <code>tm_gmtoff</code>,
10701.15Schristos    or with a time zone abbreviation member in
10711.15Schristos    <code>struct tm</code>, e.g., <code>tm_zone</code>. As noted
10721.15Schristos    in <a href="https://austingroupbugs.net/view.php?id=1533">Austin
10731.15Schristos    Group defect 1533</a>, a future version of POSIX is planned to
10741.15Schristos    require <code>tm_gmtoff</code> and <code>tm_zone</code>.
10751.3Schristos  </li>
10761.3Schristos  <li>
10771.3Schristos    Functions <code>tzalloc</code>, <code>tzfree</code>,
10781.3Schristos    <code>localtime_rz</code>, and <code>mktime_z</code> for
10791.3Schristos    more-efficient thread-safe applications that need to use multiple
10801.4Schristos    timezones.
10811.3Schristos    The <code>tzalloc</code> and <code>tzfree</code> functions
10821.3Schristos    allocate and free objects of type <code>timezone_t</code>,
10831.3Schristos    and <code>localtime_rz</code> and <code>mktime_z</code> are
10841.3Schristos    like <code>localtime_r</code> and <code>mktime</code> with an
10851.3Schristos    extra <code>timezone_t</code> argument.
10861.3Schristos    The functions were inspired by <a href="https://netbsd.org/">NetBSD</a>.
10871.3Schristos  </li>
10881.3Schristos  <li>
10891.3Schristos    Negative <code>time_t</code> values are supported, on systems
10901.3Schristos    where <code>time_t</code> is signed.
10911.3Schristos  </li>
10921.3Schristos  <li>
10931.9Schristos    These functions can account for leap seconds;
10941.9Schristos    see <a href="#leapsec">Leap seconds</a> below.
10951.3Schristos  </li>
10961.1Schristos</ul>
10971.3Schristos
10981.3Schristos<h3 id="vestigial">POSIX features no longer needed</h3>
10991.1Schristos<p>
11001.3SchristosPOSIX and <a href="https://en.wikipedia.org/wiki/ISO_C"><abbr>ISO</abbr> C</a>
11011.3Schristosdefine some <a href="https://en.wikipedia.org/wiki/API"><abbr
11021.3Schristostitle="application programming interface">API</abbr>s</a> that are vestigial:
11031.3Schristosthey are not needed, and are relics of a too-simple model that does
11041.3Schristosnot suffice to handle many real-world timestamps.
11051.3SchristosAlthough the <code><abbr>tz</abbr></code> code supports these
11061.3Schristosvestigial <abbr>API</abbr>s for backwards compatibility, they should
11071.3Schristosbe avoided in portable applications.
11081.3SchristosThe vestigial <abbr>API</abbr>s are:
11091.1Schristos</p>
11101.1Schristos<ul>
11111.1Schristos  <li>
11121.3Schristos    The POSIX <code>tzname</code> variable does not suffice and is no
11131.3Schristos    longer needed.
11141.3Schristos    To get a timestamp's time zone abbreviation, consult
11151.3Schristos    the <code>tm_zone</code> member if available; otherwise,
11161.3Schristos    use <code>strftime</code>'s <code>"%Z"</code> conversion
11171.3Schristos    specification.
11181.3Schristos  </li>
11191.3Schristos  <li>
11201.3Schristos    The POSIX <code>daylight</code> and <code>timezone</code>
11211.3Schristos    variables do not suffice and are no longer needed.
11221.3Schristos    To get a timestamp's <abbr>UT</abbr> offset, consult
11231.3Schristos    the <code>tm_gmtoff</code> member if available; otherwise,
11241.3Schristos    subtract values returned by <code>localtime</code>
11251.3Schristos    and <code>gmtime</code> using the rules of the Gregorian calendar,
11261.3Schristos    or use <code>strftime</code>'s <code>"%z"</code> conversion
11271.3Schristos    specification if a string like <code>"+0900"</code> suffices.
11281.3Schristos  </li>
11291.3Schristos  <li>
11301.3Schristos    The <code>tm_isdst</code> member is almost never needed and most of
11311.3Schristos    its uses should be discouraged in favor of the abovementioned
11321.3Schristos    <abbr>API</abbr>s.
11331.3Schristos    Although it can still be used in arguments to
11341.3Schristos    <code>mktime</code> to disambiguate timestamps near
11351.15Schristos    a <abbr>DST</abbr> transition when the clock jumps back on
11361.15Schristos    platforms lacking <code>tm_gmtoff</code>, this
11371.3Schristos    disambiguation does not work when standard time itself jumps back,
11381.3Schristos    which can occur when a location changes to a time zone with a
11391.3Schristos    lesser <abbr>UT</abbr> offset.
11401.3Schristos  </li>
11411.3Schristos</ul>
11421.3Schristos
11431.3Schristos<h3 id="other-portability">Other portability notes</h3>
11441.3Schristos<ul>
11451.3Schristos  <li>
11461.3Schristos    The <a href="https://en.wikipedia.org/wiki/Version_7_Unix">7th Edition
11471.3Schristos    UNIX</a> <code>timezone</code> function is not present in this
11481.3Schristos    package; it is impossible to reliably map <code>timezone</code>'s
11491.3Schristos    arguments (a "minutes west of <abbr>GMT</abbr>" value and a
11501.3Schristos    "daylight saving time in effect" flag) to a time zone
11511.3Schristos    abbreviation, and we refuse to guess.
11521.3Schristos    Programs that in the past used the <code>timezone</code> function
11531.3Schristos    may now examine <code>localtime(&amp;clock)-&gt;tm_zone</code>
11541.3Schristos    (if <code>TM_ZONE</code> is defined) or
11551.3Schristos    <code>tzname[localtime(&amp;clock)-&gt;tm_isdst]</code>
11561.9Schristos    (if <code>HAVE_TZNAME</code> is nonzero) to learn the correct time
11571.3Schristos    zone abbreviation to use.
11581.3Schristos  </li>
11591.3Schristos  <li>
11601.3Schristos    The <a
11611.3Schristos    href="https://en.wikipedia.org/wiki/History_of_the_Berkeley_Software_Distribution#4.2BSD"><abbr>4.2BSD</abbr></a>
11621.3Schristos    <code>gettimeofday</code> function is not
11631.3Schristos    used in this package.
11641.3Schristos    This formerly let users obtain the current <abbr>UTC</abbr> offset
11651.3Schristos    and <abbr>DST</abbr> flag, but this functionality was removed in
11661.3Schristos    later versions of <abbr>BSD</abbr>.
11671.3Schristos  </li>
11681.3Schristos  <li>
11691.3Schristos    In <abbr>SVR2</abbr>, time conversion fails for near-minimum or
11701.3Schristos    near-maximum <code>time_t</code> values when doing conversions
11711.3Schristos    for places that do not use <abbr>UT</abbr>.
11721.3Schristos    This package takes care to do these conversions correctly.
11731.3Schristos    A comment in the source code tells how to get compatibly wrong
11741.3Schristos    results.
11751.3Schristos  </li>
11761.3Schristos  <li>
11771.3Schristos    The functions that are conditionally compiled
11781.18Schristos    if <code>STD_INSPIRED</code> is nonzero should, at this point, be
11791.3Schristos    looked on primarily as food for thought.
11801.3Schristos    They are not in any sense "standard compatible" &ndash; some are
11811.3Schristos    not, in fact, specified in <em>any</em> standard.
11821.3Schristos    They do, however, represent responses of various authors to
11831.3Schristos    standardization proposals.
11841.3Schristos  </li>
11851.3Schristos  <li>
11861.4Schristos    Other time conversion proposals, in particular those supported by the
11871.4Schristos    <a href="https://howardhinnant.github.io/date/tz.html">Time Zone
11881.4Schristos    Database Parser</a>, offer a wider selection of functions
11891.3Schristos    that provide capabilities beyond those provided here.
11901.3Schristos    The absence of such functions from this package is not meant to
11911.3Schristos    discourage the development, standardization, or use of such
11921.3Schristos    functions.
11931.3Schristos    Rather, their absence reflects the decision to make this package
11941.3Schristos    contain valid extensions to POSIX, to ensure its broad
11951.3Schristos    acceptability.
11961.3Schristos    If more powerful time conversion functions can be standardized, so
11971.3Schristos    much the better.
11981.1Schristos  </li>
11991.1Schristos</ul>
12001.3Schristos</section>
12011.1Schristos
12021.3Schristos<section>
12031.3Schristos  <h2 id="stability">Interface stability</h2>
12041.1Schristos<p>
12051.3SchristosThe <code><abbr>tz</abbr></code> code and data supply the following interfaces:
12061.1Schristos</p>
12071.1Schristos
12081.1Schristos<ul>
12091.1Schristos  <li>
12101.4Schristos    A set of timezone names as per
12111.7Schristos      "<a href="#naming">Timezone identifiers</a>" above.
12121.1Schristos  </li>
12131.1Schristos  <li>
12141.3Schristos    Library functions described in "<a href="#functions">Time and date
12151.3Schristos      functions</a>" above.
12161.1Schristos  </li>
12171.1Schristos  <li>
12181.3Schristos    The programs <code>tzselect</code>, <code>zdump</code>,
12191.3Schristos    and <code>zic</code>, documented in their man pages.
12201.1Schristos  </li>
12211.1Schristos  <li>
12221.3Schristos    The format of <code>zic</code> input files, documented in
12231.3Schristos    the <code>zic</code> man page.
12241.1Schristos  </li>
12251.1Schristos  <li>
12261.3Schristos    The format of <code>zic</code> output files, documented in
12271.3Schristos    the <code>tzfile</code> man page.
12281.1Schristos  </li>
12291.1Schristos  <li>
12301.3Schristos    The format of zone table files, documented in <code>zone1970.tab</code>.
12311.1Schristos  </li>
12321.1Schristos  <li>
12331.3Schristos    The format of the country code file, documented in <code>iso3166.tab</code>.
12341.1Schristos  </li>
12351.1Schristos  <li>
12361.3Schristos    The version number of the code and data, as the first line of
12371.3Schristos    the text file '<code>version</code>' in each release.
12381.1Schristos  </li>
12391.1Schristos</ul>
12401.3Schristos
12411.1Schristos<p>
12421.1SchristosInterface changes in a release attempt to preserve compatibility with
12431.3Schristosrecent releases.
12441.3SchristosFor example, <code><abbr>tz</abbr></code> data files typically do not
12451.18Schristosrely on recently added <code>zic</code> features, so that users can
12461.3Schristosrun older <code>zic</code> versions to process newer data files.
12471.3Schristos<a href="tz-link.html#download">Downloading
12481.3Schristosthe <code><abbr>tz</abbr></code> database</a> describes how releases
12491.3Schristosare tagged and distributed.
12501.1Schristos</p>
12511.1Schristos
12521.1Schristos<p>
12531.3SchristosInterfaces not listed above are less stable.
12541.3SchristosFor example, users should not rely on particular <abbr>UT</abbr>
12551.3Schristosoffsets or abbreviations for timestamps, as data entries are often
12561.3Schristosbased on guesswork and these guesses may be corrected or improved.
12571.1Schristos</p>
12581.7Schristos
12591.7Schristos<p>
12601.7SchristosTimezone boundaries are not part of the stable interface.
12611.7SchristosFor example, even though the <samp>Asia/Bangkok</samp> timezone
12621.7Schristoscurrently includes Chang Mai, Hanoi, and Phnom Penh, this is not part
12631.7Schristosof the stable interface and the timezone can split at any time.
12641.7SchristosIf a calendar application records a future event in some location other
12651.7Schristosthan Bangkok by putting "<samp>Asia/Bangkok</samp>" in the event's record,
12661.7Schristosthe application should be robust in the presence of timezone splits
12671.7Schristosbetween now and the future time.
12681.7Schristos</p>
12691.3Schristos</section>
12701.1Schristos
12711.3Schristos<section>
12721.9Schristos  <h2 id="leapsec">Leap seconds</h2>
12731.9Schristos<p>
12741.18SchristosLeap seconds were introduced in 1972 to accommodate the
12751.18Schristosdifference between atomic time and the less regular rotation of the earth.
12761.18SchristosUnfortunately they caused so many problems with civil
12771.18Schristostimekeeping that they
12781.18Schristosare <a href="https://www.bipm.org/en/cgpm-2022/resolution-4">planned
12791.18Schristosto be discontinued by 2035</a>, with some as-yet-undetermined
12801.18Schristosmechanism replacing them, perhaps after the year 2135.
12811.18SchristosDespite their impending obsolescence, a record of leap seconds is still
12821.18Schristosneeded to resolve timestamps from 1972 through 2035.
12831.18Schristos</p>
12841.18Schristos
12851.18Schristos<p>
12861.9SchristosThe <code><abbr>tz</abbr></code> code and data can account for leap seconds,
12871.9Schristosthanks to code contributed by Bradley White.
12881.9SchristosHowever, the leap second support of this package is rarely used directly
12891.9Schristosbecause POSIX requires leap seconds to be excluded and many
12901.9Schristossoftware packages would mishandle leap seconds if they were present.
12911.9SchristosInstead, leap seconds are more commonly handled by occasionally adjusting
12921.9Schristosthe operating system kernel clock as described in
12931.9Schristos<a href="tz-link.html#precision">Precision timekeeping</a>,
12941.9Schristosand this package by default installs a <samp>leapseconds</samp> file
12951.9Schristoscommonly used by
12961.15Schristos<a href="https://www.ntp.org"><abbr title="Network Time Protocol">NTP</abbr></a>
12971.9Schristossoftware that adjusts the kernel clock.
12981.9SchristosHowever, kernel-clock twiddling approximates UTC only roughly,
12991.18Schristosand systems needing more precise UTC can use this package's leap
13001.9Schristossecond support directly.
13011.9Schristos</p>
13021.9Schristos
13031.9Schristos<p>
13041.18SchristosThe directly supported mechanism assumes that <code>time_t</code>
13051.9Schristoscounts of seconds since the POSIX epoch normally include leap seconds,
13061.9Schristosas opposed to POSIX <code>time_t</code> counts which exclude leap seconds.
13071.9SchristosThis modified timescale is converted to <abbr>UTC</abbr>
13081.12Schristosat the same point that time zone and <abbr>DST</abbr>
13091.12Schristosadjustments are applied &ndash;
13101.9Schristosnamely, at calls to <code>localtime</code> and analogous functions &ndash;
13111.9Schristosand the process is driven by leap second information
13121.9Schristosstored in alternate versions of the <abbr>TZif</abbr> files.
13131.9SchristosBecause a leap second adjustment may be needed even
13141.9Schristosif no time zone correction is desired,
13151.9Schristoscalls to <code>gmtime</code>-like functions
13161.9Schristosalso need to consult a <abbr>TZif</abbr> file,
13171.14Schristosconventionally named <samp><abbr>Etc/UTC</abbr></samp>
13181.14Schristos(<samp><abbr>GMT</abbr></samp> in previous versions),
13191.9Schristosto see whether leap second corrections are needed.
13201.9SchristosTo convert an application's <code>time_t</code> timestamps to or from
13211.9SchristosPOSIX <code>time_t</code> timestamps (for use when, say,
13221.9Schristosembedding or interpreting timestamps in portable
13231.9Schristos<a href="https://en.wikipedia.org/wiki/Tar_(computing)"><code>tar</code></a>
13241.9Schristosfiles),
13251.9Schristosthe application can call the utility functions
13261.9Schristos<code>time2posix</code> and <code>posix2time</code>
13271.9Schristosincluded with this package.
13281.9Schristos</p>
13291.9Schristos
13301.9Schristos<p>
13311.9SchristosIf the POSIX-compatible <abbr>TZif</abbr> file set is installed
13321.9Schristosin a directory whose basename is <samp>zoneinfo</samp>, the
13331.9Schristosleap-second-aware file set is by default installed in a separate
13341.9Schristosdirectory <samp>zoneinfo-leaps</samp>.
13351.9SchristosAlthough each process can have its own time zone by setting
13361.9Schristosits <code>TZ</code> environment variable, there is no support for some
13371.9Schristosprocesses being leap-second aware while other processes are
13381.9SchristosPOSIX-compatible; the leap-second choice is system-wide.
13391.9SchristosSo if you configure your kernel to count leap seconds, you should also
13401.9Schristosdiscard <samp>zoneinfo</samp> and rename <samp>zoneinfo-leaps</samp>
13411.9Schristosto <samp>zoneinfo</samp>.
13421.9SchristosAlternatively, you can install just one set of <abbr>TZif</abbr> files
13431.9Schristosin the first place; see the <code>REDO</code> variable in this package's
13441.9Schristos<a href="https://en.wikipedia.org/wiki/Makefile">makefile</a>.
13451.9Schristos</p>
13461.9Schristos</section>
13471.9Schristos
13481.9Schristos<section>
13491.3Schristos  <h2 id="calendar">Calendrical issues</h2>
13501.1Schristos<p>
13511.1SchristosCalendrical issues are a bit out of scope for a time zone database,
13521.1Schristosbut they indicate the sort of problems that we would run into if we
13531.3Schristosextended the time zone database further into the past.
13541.3SchristosAn excellent resource in this area is Edward M. Reingold
13551.3Schristosand Nachum Dershowitz, <cite><a
13561.3Schristoshref="https://www.cambridge.org/fr/academic/subjects/computer-science/computing-general-interest/calendrical-calculations-ultimate-edition-4th-edition">Calendrical
13571.3SchristosCalculations: The Ultimate Edition</a></cite>, Cambridge University Press (2018).
13581.3SchristosOther information and sources are given in the file '<code>calendars</code>'
13591.3Schristosin the <code><abbr>tz</abbr></code> distribution.
13601.3SchristosThey sometimes disagree.
13611.3Schristos</p>
13621.3Schristos</section>
13631.3Schristos
13641.3Schristos<section>
13651.18Schristos  <h2 id="planets">Time and time zones off Earth</h2>
13661.18Schristos<p>
13671.18SchristosThe European Space Agency is <a
13681.18Schristoshref='https://www.esa.int/Applications/Navigation/Telling_time_on_the_Moon'>considering</a>
13691.18Schristosthe establishment of a reference timescale for the Moon, which has
13701.18Schristosdays roughly equivalent to 29.5 Earth days, and where relativistic
13711.18Schristoseffects cause clocks to tick slightly faster than on Earth.
13721.18Schristos</p>
13731.18Schristos
13741.3Schristos<p>
13751.10SchristosSome people's work schedules have used
13761.10Schristos<a href="https://en.wikipedia.org/wiki/Timekeeping_on_Mars">Mars time</a>.
13771.3SchristosJet Propulsion Laboratory (JPL) coordinators kept Mars time on
13781.3Schristosand off during the
13791.6Schristos<a href="https://en.wikipedia.org/wiki/Mars_Pathfinder">Mars
13801.10SchristosPathfinder</a> mission (1997).
13811.3SchristosSome of their family members also adapted to Mars time.
13821.3SchristosDozens of special Mars watches were built for JPL workers who kept
13831.10SchristosMars time during the
13841.10Schristos<a href="https://en.wikipedia.org/wiki/Mars_Exploration_Rover">Mars
13851.10SchristosExploration Rovers (MER)</a> mission (2004&ndash;2018).
13861.10SchristosThese timepieces looked like normal Seikos and Citizens but were adjusted
13871.10Schristosto use Mars seconds rather than terrestrial seconds, although
13881.10Schristosunfortunately the adjusted watches were unreliable and appear to have
13891.10Schristoshad only limited use.
13901.1Schristos</p>
13911.1Schristos
13921.1Schristos<p>
13931.1SchristosA Mars solar day is called a "sol" and has a mean period equal to
13941.3Schristosabout 24 hours 39 minutes 35.244 seconds in terrestrial time.
13951.3SchristosIt is divided into a conventional 24-hour clock, so each Mars second
13961.3Schristosequals about 1.02749125 terrestrial seconds.
13971.10Schristos(One MER worker noted, "If I am working Mars hours, and Mars hours are
13981.10Schristos2.5% more than Earth hours, shouldn't I get an extra 2.5% pay raise?")
13991.1Schristos</p>
14001.1Schristos
14011.1Schristos<p>
14021.3SchristosThe <a href="https://en.wikipedia.org/wiki/Prime_meridian">prime
14031.3Schristosmeridian</a> of Mars goes through the center of the crater
14041.3Schristos<a href="https://en.wikipedia.org/wiki/Airy-0">Airy-0</a>, named in
14051.3Schristoshonor of the British astronomer who built the Greenwich telescope that
14061.3Schristosdefines Earth's prime meridian.
14071.3SchristosMean solar time on the Mars prime meridian is
14081.6Schristoscalled Mars Coordinated Time (<abbr>MTC</abbr>).
14091.1Schristos</p>
14101.1Schristos
14111.1Schristos<p>
14121.1SchristosEach landed mission on Mars has adopted a different reference for
14131.4Schristossolar timekeeping, so there is no real standard for Mars time zones.
14141.10SchristosFor example, the MER mission defined two time zones "Local
14151.3SchristosSolar Time A" and "Local Solar Time B" for its two missions, each zone
14161.3Schristosdesigned so that its time equals local true solar time at
14171.3Schristosapproximately the middle of the nominal mission.
14181.10SchristosThe A and B zones differ enough so that an MER worker assigned to
14191.10Schristosthe A zone might suffer "Mars lag" when switching to work in the B zone.
14201.3SchristosSuch a "time zone" is not particularly suited for any application
14211.3Schristosother than the mission itself.
14221.1Schristos</p>
14231.1Schristos
14241.1Schristos<p>
14251.1SchristosMany calendars have been proposed for Mars, but none have achieved
14261.3Schristoswide acceptance.
14271.3SchristosAstronomers often use Mars Sol Date (<abbr>MSD</abbr>) which is a
14281.1Schristossequential count of Mars solar days elapsed since about 1873-12-29
14291.3Schristos12:00 <abbr>GMT</abbr>.
14301.1Schristos</p>
14311.1Schristos
14321.1Schristos<p>
14331.1SchristosIn our solar system, Mars is the planet with time and calendar most
14341.3Schristoslike Earth's.
14351.3SchristosOn other planets, Sun-based time and calendars would work quite
14361.3Schristosdifferently.
14371.3SchristosFor example, although Mercury's
14381.3Schristos<a href="https://en.wikipedia.org/wiki/Rotation_period">sidereal
14391.3Schristosrotation period</a> is 58.646 Earth days, Mercury revolves around the
14401.3SchristosSun so rapidly that an observer on Mercury's equator would see a
14411.3Schristossunrise only every 175.97 Earth days, i.e., a Mercury year is 0.5 of a
14421.3SchristosMercury day.
14431.3SchristosVenus is more complicated, partly because its rotation is slightly
14441.3Schristos<a href="https://en.wikipedia.org/wiki/Retrograde_motion">retrograde</a>:
14451.3Schristosits year is 1.92 of its days.
14461.3SchristosGas giants like Jupiter are trickier still, as their polar and
14471.3Schristosequatorial regions rotate at different rates, so that the length of a
14481.3Schristosday depends on latitude.
14491.3SchristosThis effect is most pronounced on Neptune, where the day is about 12
14501.3Schristoshours at the poles and 18 hours at the equator.
14511.1Schristos</p>
14521.1Schristos
14531.1Schristos<p>
14541.3SchristosAlthough the <code><abbr>tz</abbr></code> database does not support
14551.3Schristostime on other planets, it is documented here in the hopes that support
14561.3Schristoswill be added eventually.
14571.1Schristos</p>
14581.1Schristos
14591.1Schristos<p>
14601.3SchristosSources for time on other planets:
14611.1Schristos</p>
14621.3Schristos
14631.1Schristos<ul>
14641.1Schristos  <li>
14651.3Schristos    Michael Allison and Robert Schmunk,
14661.3Schristos    "<a href="https://www.giss.nasa.gov/tools/mars24/help/notes.html">Technical
14671.3Schristos      Notes on Mars Solar Time as Adopted by the Mars24 Sunclock</a>"
14681.10Schristos    (2020-03-08).
14691.10Schristos  </li>
14701.10Schristos  <li>
14711.10Schristos    Zara Mirmalek,
14721.10Schristos    <em><a href="https://mitpress.mit.edu/books/making-time-mars">Making
14731.10Schristos	Time on Mars</a></em>, MIT Press (March 2020), ISBN 978-0262043854.
14741.1Schristos  </li>
14751.1Schristos  <li>
14761.3Schristos    Jia-Rui Chong,
14771.8Schristos    "<a href="https://www.latimes.com/archives/la-xpm-2004-jan-14-sci-marstime14-story.html">Workdays
14781.3Schristos    Fit for a Martian</a>", <cite>Los Angeles Times</cite>
14791.3Schristos    (2004-01-14), pp A1, A20&ndash;A21.
14801.1Schristos  </li>
14811.1Schristos  <li>
14821.3Schristos    Tom Chmielewski,
14831.3Schristos    "<a href="https://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/">Jet
14841.3Schristos    Lag Is Worse on Mars</a>", <cite>The Atlantic</cite> (2015-02-26)
14851.1Schristos  </li>
14861.1Schristos  <li>
14871.3Schristos    Matt Williams,
14881.3Schristos    "<a href="https://www.universetoday.com/37481/days-of-the-planets/">How
14891.3Schristos    long is a day on the other planets of the solar system?</a>"
14901.4Schristos    (2016-01-20).
14911.1Schristos  </li>
14921.1Schristos</ul>
14931.3Schristos</section>
14941.1Schristos
14951.3Schristos<footer>
14961.3Schristos  <hr>
14971.3Schristos  This file is in the public domain, so clarified as of 2009-05-17 by
14981.3Schristos  Arthur David Olson.
14991.3Schristos</footer>
15001.1Schristos</body>
15011.1Schristos</html>
1502