theory.html revision 1.1
11.1Schristos<!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.1Schristos</head>
71.1Schristos
81.1Schristos<!-- The somewhat-unusal indenting style in this file is intended to
91.1Schristos     shrink the output of the shell command 'diff Theory Theory.html',
101.1Schristos     where 'Theory' was the plain text file that this file is derived
111.1Schristos     from.  The 'Theory' file used leading white space to indent, and
121.1Schristos     when possible that indentation is preserved here.  Eventually we
131.1Schristos     may stop doing this and remove this comment.  -->
141.1Schristos
151.1Schristos<body>
161.1Schristos  <h1>Theory and pragmatics of the tz code and data</h1>
171.1Schristos  <h3>Outline</h3>
181.1Schristos  <nav>
191.1Schristos    <ul>
201.1Schristos      <li><a href="#scope">Scope of the tz database</a></li>
211.1Schristos      <li><a href="#naming">Names of time zone rules</a></li>
221.1Schristos      <li><a href="#abbreviations">Time zone abbreviations</a></li>
231.1Schristos      <li><a href="#accuracy">Accuracy of the tz database</a></li>
241.1Schristos      <li><a href="#functions">Time and date functions</a></li>
251.1Schristos      <li><a href="#stability">Interface stability</a></li>
261.1Schristos      <li><a href="#calendar">Calendrical issues</a></li>
271.1Schristos      <li><a href="#planets">Time and time zones on other planets</a></li>
281.1Schristos    </ul>
291.1Schristos  </nav>
301.1Schristos
311.1Schristos
321.1Schristos  <section>
331.1Schristos    <h2 id="scope">Scope of the tz database</h2>
341.1Schristos<p>
351.1SchristosThe tz database attempts to record the history and predicted future of
361.1Schristosall computer-based clocks that track civil time.  To represent this
371.1Schristosdata, the world is partitioned into regions whose clocks all agree
381.1Schristosabout timestamps that occur after the somewhat-arbitrary cutoff point
391.1Schristosof the POSIX Epoch (1970-01-01 00:00:00 UTC).  For each such region,
401.1Schristosthe database records all known clock transitions, and labels the region
411.1Schristoswith a notable location.  Although 1970 is a somewhat-arbitrary
421.1Schristoscutoff, there are significant challenges to moving the cutoff earlier
431.1Schristoseven by a decade or two, due to the wide variety of local practices
441.1Schristosbefore computer timekeeping became prevalent.
451.1Schristos</p>
461.1Schristos
471.1Schristos<p>
481.1SchristosClock transitions before 1970 are recorded for each such location,
491.1Schristosbecause most systems support timestamps before 1970 and could
501.1Schristosmisbehave if data entries were omitted for pre-1970 transitions.
511.1SchristosHowever, the database is not designed for and does not suffice for
521.1Schristosapplications requiring accurate handling of all past times everywhere,
531.1Schristosas it would take far too much effort and guesswork to record all
541.1Schristosdetails of pre-1970 civil timekeeping.
551.1Schristos</p>
561.1Schristos
571.1Schristos<p>
581.1SchristosAs described below, reference source code for using the tz database is
591.1Schristosalso available.  The tz code is upwards compatible with POSIX, an
601.1Schristosinternational standard for UNIX-like systems.  As of this writing, the
611.1Schristoscurrent edition of POSIX is:
621.1Schristos  <a href="http://pubs.opengroup.org/onlinepubs/9699919799/">
631.1Schristos  The Open Group Base Specifications Issue 7</a>,
641.1Schristos  IEEE Std 1003.1-2008, 2016 Edition.
651.1Schristos</p>
661.1Schristos  </section>
671.1Schristos
681.1Schristos
691.1Schristos
701.1Schristos  <section>
711.1Schristos    <h2 id="naming">Names of time zone rules</h2>
721.1Schristos<p>
731.1SchristosEach of the database's time zone rules has a unique name.
741.1SchristosInexperienced users are not expected to select these names unaided.
751.1SchristosDistributors should provide documentation and/or a simple selection
761.1Schristosinterface that explains the names; for one example, see the 'tzselect'
771.1Schristosprogram in the tz code.  The
781.1Schristos<a href="http://cldr.unicode.org/">Unicode Common Locale Data
791.1SchristosRepository</a> contains data that may be useful for other
801.1Schristosselection interfaces.
811.1Schristos</p>
821.1Schristos
831.1Schristos<p>
841.1SchristosThe time zone rule naming conventions attempt to strike a balance
851.1Schristosamong the following goals:
861.1Schristos</p>
871.1Schristos<ul>
881.1Schristos  <li>
891.1Schristos   Uniquely identify every region where clocks have agreed since 1970.
901.1Schristos   This is essential for the intended use: static clocks keeping local
911.1Schristos   civil time.
921.1Schristos  </li>
931.1Schristos  <li>
941.1Schristos   Indicate to experts where that region is.
951.1Schristos  </li>
961.1Schristos  <li>
971.1Schristos   Be robust in the presence of political changes.  For example, names
981.1Schristos   of countries are ordinarily not used, to avoid incompatibilities
991.1Schristos   when countries change their name (e.g. Zaire&rarr;Congo) or when
1001.1Schristos   locations change countries (e.g. Hong Kong from UK colony to
1011.1Schristos   China).
1021.1Schristos  </li>
1031.1Schristos  <li>
1041.1Schristos   Be portable to a wide variety of implementations.
1051.1Schristos  </li>
1061.1Schristos  <li>
1071.1Schristos   Use a consistent naming conventions over the entire world.
1081.1Schristos  </li>
1091.1Schristos</ul>
1101.1Schristos<p>
1111.1SchristosNames normally have the
1121.1Schristosform <var>AREA</var><code>/</code><var>LOCATION</var>,
1131.1Schristoswhere <var>AREA</var> is the name of a continent or ocean,
1141.1Schristosand <var>LOCATION</var> is the name of a specific
1151.1Schristoslocation within that region.  North and South America share the same
1161.1Schristosarea, '<code>America</code>'.  Typical names are
1171.1Schristos'<code>Africa/Cairo</code>', '<code>America/New_York</code>', and
1181.1Schristos'<code>Pacific/Honolulu</code>'.
1191.1Schristos</p>
1201.1Schristos
1211.1Schristos<p>
1221.1SchristosHere are the general rules used for choosing location names,
1231.1Schristosin decreasing order of importance:
1241.1Schristos</p>
1251.1Schristos<ul>
1261.1Schristos  <li>
1271.1Schristos	Use only valid POSIX file name components (i.e., the parts of
1281.1Schristos		names other than '<code>/</code>').  Do not use the file name
1291.1Schristos		components '<code>.</code>' and '<code>..</code>'.
1301.1Schristos		Within a file name component,
1311.1Schristos		use only ASCII letters, '<code>.</code>',
1321.1Schristos		'<code>-</code>' and '<code>_</code>'.  Do not use
1331.1Schristos		digits, as that might create an ambiguity with POSIX
1341.1Schristos		TZ strings.  A file name component must not exceed 14
1351.1Schristos		characters or start with '<code>-</code>'.  E.g.,
1361.1Schristos		prefer '<code>Brunei</code>' to
1371.1Schristos		'<code>Bandar_Seri_Begawan</code>'.  Exceptions: see
1381.1Schristos		the discussion
1391.1Schristos		of legacy names below.
1401.1Schristos  </li>
1411.1Schristos  <li>
1421.1Schristos	A name must not be empty, or contain '<code>//</code>', or
1431.1Schristos	start or end with '<code>/</code>'.
1441.1Schristos  </li>
1451.1Schristos  <li>
1461.1Schristos	Do not use names that differ only in case.  Although the reference
1471.1Schristos		implementation is case-sensitive, some other implementations
1481.1Schristos		are not, and they would mishandle names differing only in case.
1491.1Schristos  </li>
1501.1Schristos  <li>
1511.1Schristos	If one name <var>A</var> is an initial prefix of another
1521.1Schristos		name <var>AB</var> (ignoring case), then <var>B</var>
1531.1Schristos		must not start with '<code>/</code>', as a
1541.1Schristos		regular file cannot have
1551.1Schristos		the same name as a directory in POSIX.  For example,
1561.1Schristos		'<code>America/New_York</code>' precludes
1571.1Schristos		'<code>America/New_York/Bronx</code>'.
1581.1Schristos  </li>
1591.1Schristos  <li>
1601.1Schristos	Uninhabited regions like the North Pole and Bouvet Island
1611.1Schristos		do not need locations, since local time is not defined there.
1621.1Schristos  </li>
1631.1Schristos  <li>
1641.1Schristos	There should typically be at least one name for each ISO 3166-1
1651.1Schristos		officially assigned two-letter code for an inhabited country
1661.1Schristos		or territory.
1671.1Schristos  </li>
1681.1Schristos  <li>
1691.1Schristos	If all the clocks in a region have agreed since 1970,
1701.1Schristos		don't bother to include more than one location
1711.1Schristos		even if subregions' clocks disagreed before 1970.
1721.1Schristos		Otherwise these tables would become annoyingly large.
1731.1Schristos  </li>
1741.1Schristos  <li>
1751.1Schristos	If a name is ambiguous, use a less ambiguous alternative;
1761.1Schristos		e.g. many cities are named San José and Georgetown, so
1771.1Schristos		prefer '<code>Costa_Rica</code>' to '<code>San_Jose</code>' and '<code>Guyana</code>' to '<code>Georgetown</code>'.
1781.1Schristos  </li>
1791.1Schristos  <li>
1801.1Schristos	Keep locations compact.  Use cities or small islands, not countries
1811.1Schristos		or regions, so that any future time zone changes do not split
1821.1Schristos		locations into different time zones.  E.g. prefer
1831.1Schristos		'<code>Paris</code>' to '<code>France</code>', since
1841.1Schristos		France has had multiple time zones.
1851.1Schristos  </li>
1861.1Schristos  <li>
1871.1Schristos	Use mainstream English spelling, e.g. prefer
1881.1Schristos		'<code>Rome</code>' to '<code>Roma</code>', and prefer
1891.1Schristos		'<code>Athens</code>' to the Greek
1901.1Schristos		'<code>Αθήνα</code>' or the Romanized
1911.1Schristos		'<code>Athína</code>'.
1921.1Schristos		The POSIX file name restrictions encourage this rule.
1931.1Schristos  </li>
1941.1Schristos  <li>
1951.1Schristos	Use the most populous among locations in a zone,
1961.1Schristos		e.g. prefer '<code>Shanghai</code>' to
1971.1Schristos		'<code>Beijing</code>'.  Among locations with
1981.1Schristos		similar populations, pick the best-known location,
1991.1Schristos		e.g. prefer '<code>Rome</code>' to '<code>Milan</code>'.
2001.1Schristos  </li>
2011.1Schristos  <li>
2021.1Schristos	Use the singular form, e.g. prefer '<code>Canary</code>' to '<code>Canaries</code>'.
2031.1Schristos  </li>
2041.1Schristos  <li>
2051.1Schristos	Omit common suffixes like '<code>_Islands</code>' and
2061.1Schristos		'<code>_City</code>', unless that would lead to
2071.1Schristos		ambiguity.  E.g. prefer '<code>Cayman</code>' to
2081.1Schristos		'<code>Cayman_Islands</code>' and
2091.1Schristos		'<code>Guatemala</code>' to
2101.1Schristos		'<code>Guatemala_City</code>', but prefer
2111.1Schristos		'<code>Mexico_City</code>' to '<code>Mexico</code>'
2121.1Schristos		because the country
2131.1Schristos		of Mexico has several time zones.
2141.1Schristos  </li>
2151.1Schristos  <li>
2161.1Schristos	Use '<code>_</code>' to represent a space.
2171.1Schristos  </li>
2181.1Schristos  <li>
2191.1Schristos	Omit '<code>.</code>' from abbreviations in names, e.g. prefer
2201.1Schristos		'<code>St_Helena</code>' to '<code>St._Helena</code>'.
2211.1Schristos  </li>
2221.1Schristos  <li>
2231.1Schristos	Do not change established names if they only marginally
2241.1Schristos		violate the above rules.  For example, don't change
2251.1Schristos		the existing name '<code>Rome</code>' to
2261.1Schristos		'<code>Milan</code>' merely because
2271.1Schristos		Milan's population has grown to be somewhat greater
2281.1Schristos		than Rome's.
2291.1Schristos  </li>
2301.1Schristos  <li>
2311.1Schristos	If a name is changed, put its old spelling in the
2321.1Schristos		'<code>backward</code>' file.
2331.1Schristos		This means old spellings will continue to work.
2341.1Schristos  </li>
2351.1Schristos</ul>
2361.1Schristos
2371.1Schristos<p>
2381.1SchristosThe file '<code>zone1970.tab</code>' lists geographical locations used
2391.1Schristosto name time
2401.1Schristoszone rules.  It is intended to be an exhaustive list of names for
2411.1Schristosgeographic regions as described above; this is a subset of the names
2421.1Schristosin the data.  Although a '<code>zone1970.tab</code>' location's longitude
2431.1Schristoscorresponds to its LMT offset with one hour for every 15 degrees east
2441.1Schristoslongitude, this relationship is not exact.
2451.1Schristos</p>
2461.1Schristos
2471.1Schristos<p>
2481.1SchristosOlder versions of this package used a different naming scheme,
2491.1Schristosand these older names are still supported.
2501.1SchristosSee the file '<code>backward</code>' for most of these older names
2511.1Schristos(e.g., '<code>US/Eastern</code>' instead of '<code>America/New_York</code>').
2521.1SchristosThe other old-fashioned names still supported are
2531.1Schristos'<code>WET</code>', '<code>CET</code>', '<code>MET</code>', and '<code>EET</code>' (see the file '<code>europe</code>').
2541.1Schristos</p>
2551.1Schristos
2561.1Schristos<p>
2571.1SchristosOlder versions of this package defined legacy names that are
2581.1Schristosincompatible with the first rule of location names, but which are
2591.1Schristosstill supported.  These legacy names are mostly defined in the file
2601.1Schristos'<code>etcetera</code>'.  Also, the file '<code>backward</code>' defines the legacy names
2611.1Schristos'<code>GMT0</code>', '<code>GMT-0</code>' and '<code>GMT+0</code>', and the file '<code>northamerica</code>' defines the
2621.1Schristoslegacy names '<code>EST5EDT</code>', '<code>CST6CDT</code>', '<code>MST7MDT</code>', and '<code>PST8PDT</code>'.
2631.1Schristos</p>
2641.1Schristos
2651.1Schristos<p>
2661.1SchristosExcluding '<code>backward</code>' should not affect the other data.  If
2671.1Schristos'<code>backward</code>' is excluded, excluding '<code>etcetera</code>' should not affect the
2681.1Schristosremaining data.
2691.1Schristos</p>
2701.1Schristos
2711.1Schristos
2721.1Schristos  </section>
2731.1Schristos  <section>
2741.1Schristos    <h2 id="abbreviations">Time zone abbreviations</h2>
2751.1Schristos<p>
2761.1SchristosWhen this package is installed, it generates time zone abbreviations
2771.1Schristoslike '<code>EST</code>' to be compatible with human tradition and POSIX.
2781.1SchristosHere are the general rules used for choosing time zone abbreviations,
2791.1Schristosin decreasing order of importance:
2801.1Schristos<ul>
2811.1Schristos  <li>
2821.1Schristos	Use three or more characters that are ASCII alphanumerics or
2831.1Schristos		'<code>+</code>' or '<code>-</code>'.
2841.1Schristos		Previous editions of this database also used characters like
2851.1Schristos		'<code> </code>' and '<code>?</code>', but these
2861.1Schristos		characters have a special meaning to
2871.1Schristos		the shell and cause commands like
2881.1Schristos			'<code>set `date`</code>'
2891.1Schristos		to have unexpected effects.
2901.1Schristos		Previous editions of this rule required upper-case letters,
2911.1Schristos		but the Congressman who introduced Chamorro Standard Time
2921.1Schristos		preferred "ChST", so lower-case letters are now allowed.
2931.1Schristos		Also, POSIX from 2001 on relaxed the rule to allow
2941.1Schristos		'<code>-</code>', '<code>+</code>',
2951.1Schristos		and alphanumeric characters from the portable character set
2961.1Schristos		in the current locale.  In practice ASCII alphanumerics and
2971.1Schristos		'<code>+</code>' and '<code>-</code>' are safe in all locales.
2981.1Schristos
2991.1Schristos		In other words, in the C locale the POSIX extended regular
3001.1Schristos		expression <code>[-+[:alnum:]]{3,}</code> should match
3011.1Schristos		the abbreviation.
3021.1Schristos		This guarantees that all abbreviations could have been
3031.1Schristos		specified by a POSIX TZ string.
3041.1Schristos  </li>
3051.1Schristos  <li>
3061.1Schristos	Use abbreviations that are in common use among English-speakers,
3071.1Schristos		e.g. 'EST' for Eastern Standard Time in North America.
3081.1Schristos		We assume that applications translate them to other languages
3091.1Schristos		as part of the normal localization process; for example,
3101.1Schristos		a French application might translate 'EST' to 'HNE'.
3111.1Schristos  </li>
3121.1Schristos  <li>
3131.1Schristos	For zones whose times are taken from a city's longitude, use the
3141.1Schristos		traditional <var>x</var>MT notation, e.g. 'PMT' for
3151.1Schristos		Paris Mean Time.
3161.1Schristos		The only name like this in current use is 'GMT'.
3171.1Schristos  </li>
3181.1Schristos  <li>
3191.1Schristos	Use 'LMT' for local mean time of locations before the introduction
3201.1Schristos		of standard time; see "<a href="#scope">Scope of the
3211.1Schristos		tz database</a>".
3221.1Schristos  </li>
3231.1Schristos  <li>
3241.1Schristos	If there is no common English abbreviation, use numeric offsets like
3251.1Schristos		<code>-</code>05 and <code>+</code>0830 that are
3261.1Schristos		generated by zic's <code>%z</code> notation.
3271.1Schristos  </li>
3281.1Schristos  <li>
3291.1Schristos	Use current abbreviations for older timestamps to avoid confusion.
3301.1Schristos		For example, in 1910 a common English abbreviation for UT +01
3311.1Schristos		in central Europe was 'MEZ' (short for both "Middle European
3321.1Schristos		Zone" and for "Mitteleuropäische Zeit" in German).  Nowadays
3331.1Schristos		'CET' ("Central European Time") is more common in English, and
3341.1Schristos		the database uses 'CET' even for circa-1910 timestamps as this
3351.1Schristos		is less confusing for modern users and avoids the need for
3361.1Schristos		determining when 'CET' supplanted 'MEZ' in common usage.
3371.1Schristos  </li>
3381.1Schristos  <li>
3391.1Schristos	Use a consistent style in a zone's history.  For example, if a zone's
3401.1Schristos		history tends to use numeric abbreviations and a particular
3411.1Schristos		entry could go either way, use a numeric abbreviation.
3421.1Schristos  </li>
3431.1Schristos</ul>
3441.1Schristos    [The remaining guidelines predate the introduction of <code>%z</code>.
3451.1Schristos    They are problematic as they mean tz data entries invent
3461.1Schristos    notation rather than record it.  These guidelines are now
3471.1Schristos    deprecated and the plan is to gradually move to <code>%z</code> for
3481.1Schristos    inhabited locations and to "<code>-</code>00" for uninhabited locations.]
3491.1Schristos<ul>
3501.1Schristos  <li>
3511.1Schristos	If there is no common English abbreviation, abbreviate the English
3521.1Schristos		translation of the usual phrase used by native speakers.
3531.1Schristos		If this is not available or is a phrase mentioning the country
3541.1Schristos		(e.g. "Cape Verde Time"), then:
3551.1Schristos	<ul>
3561.1Schristos	  <li>
3571.1Schristos		When a country is identified with a single or principal zone,
3581.1Schristos			append 'T' to the country's ISO	code, e.g. 'CVT' for
3591.1Schristos			Cape Verde Time.  For summer time append 'ST';
3601.1Schristos			for double summer time append 'DST'; etc.
3611.1Schristos	  </li>
3621.1Schristos	  <li>
3631.1Schristos		Otherwise, take the first three letters of an English place
3641.1Schristos			name identifying each zone and append 'T', 'ST', etc.
3651.1Schristos			as before; e.g. 'CHAST' for CHAtham Summer Time.
3661.1Schristos	  </li>
3671.1Schristos	</ul>
3681.1Schristos  </li>
3691.1Schristos  <li>
3701.1Schristos	Use UT (with time zone abbreviation '<code>-</code>00') for
3711.1Schristos		locations while uninhabited.  The leading
3721.1Schristos		'<code>-</code>' is a flag that the time
3731.1Schristos		zone is in some sense undefined; this notation is
3741.1Schristos		derived from Internet RFC 3339.
3751.1Schristos  </li>
3761.1Schristos</ul>
3771.1Schristos<p>
3781.1SchristosApplication writers should note that these abbreviations are ambiguous
3791.1Schristosin practice: e.g. 'CST' has a different meaning in China than
3801.1Schristosit does in the United States.  In new applications, it's often better
3811.1Schristosto use numeric UT offsets like '<code>-</code>0600' instead of time zone
3821.1Schristosabbreviations like 'CST'; this avoids the ambiguity.
3831.1Schristos</p>
3841.1Schristos  </section>
3851.1Schristos
3861.1Schristos
3871.1Schristos  <section>
3881.1Schristos    <h2 id="accuracy">Accuracy of the tz database</h2>
3891.1Schristos<p>
3901.1SchristosThe tz database is not authoritative, and it surely has errors.
3911.1SchristosCorrections are welcome and encouraged; see the file CONTRIBUTING.
3921.1SchristosUsers requiring authoritative data should consult national standards
3931.1Schristosbodies and the references cited in the database's comments.
3941.1Schristos</p>
3951.1Schristos
3961.1Schristos<p>
3971.1SchristosErrors in the tz database arise from many sources:
3981.1Schristos</p>
3991.1Schristos<ul>
4001.1Schristos  <li>
4011.1Schristos   The tz database predicts future timestamps, and current predictions
4021.1Schristos   will be incorrect after future governments change the rules.
4031.1Schristos   For example, if today someone schedules a meeting for 13:00 next
4041.1Schristos   October 1, Casablanca time, and tomorrow Morocco changes its
4051.1Schristos   daylight saving rules, software can mess up after the rule change
4061.1Schristos   if it blithely relies on conversions made before the change.
4071.1Schristos  </li>
4081.1Schristos  <li>
4091.1Schristos   The pre-1970 entries in this database cover only a tiny sliver of how
4101.1Schristos   clocks actually behaved; the vast majority of the necessary
4111.1Schristos   information was lost or never recorded.  Thousands more zones would
4121.1Schristos   be needed if the tz database's scope were extended to cover even
4131.1Schristos   just the known or guessed history of standard time; for example,
4141.1Schristos   the current single entry for France would need to split into dozens
4151.1Schristos   of entries, perhaps hundreds.  And in most of the world even this
4161.1Schristos   approach would be misleading due to widespread disagreement or
4171.1Schristos   indifference about what times should be observed.  In her 2015 book
4181.1Schristos   <cite>The Global Transformation of Time, 1870-1950</cite>, Vanessa Ogle writes
4191.1Schristos   "Outside of Europe and North America there was no system of time
4201.1Schristos   zones at all, often not even a stable landscape of mean times,
4211.1Schristos   prior to the middle decades of the twentieth century".  See:
4221.1Schristos   Timothy Shenk, <a
4231.1Schristos   href="https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle">Booked:
4241.1Schristos   A Global History of Time</a>. <cite>Dissent</cite> 2015-12-17.
4251.1Schristos  </li>
4261.1Schristos  <li>
4271.1Schristos   Most of the pre-1970 data entries come from unreliable sources, often
4281.1Schristos   astrology books that lack citations and whose compilers evidently
4291.1Schristos   invented entries when the true facts were unknown, without
4301.1Schristos   reporting which entries were known and which were invented.
4311.1Schristos   These books often contradict each other or give implausible entries,
4321.1Schristos   and on the rare occasions when they are checked they are
4331.1Schristos   typically found to be incorrect.
4341.1Schristos  </li>
4351.1Schristos  <li>
4361.1Schristos   For the UK the tz database relies on years of first-class work done by
4371.1Schristos   Joseph Myers and others; see
4381.1Schristos   "<a href="https://www.polyomino.org.uk/british-time/">History of
4391.1Schristos   legal time in Britain</a>".
4401.1Schristos   Other countries are not done nearly as well.
4411.1Schristos  </li>
4421.1Schristos  <li>
4431.1Schristos   Sometimes, different people in the same city would maintain clocks
4441.1Schristos   that differed significantly.  Railway time was used by railroad
4451.1Schristos   companies (which did not always agree with each other),
4461.1Schristos   church-clock time was used for birth certificates, etc.
4471.1Schristos   Often this was merely common practice, but sometimes it was set by law.
4481.1Schristos   For example, from 1891 to 1911 the UT offset in France was legally
4491.1Schristos   0:09:21 outside train stations and 0:04:21 inside.
4501.1Schristos  </li>
4511.1Schristos  <li>
4521.1Schristos   Although a named location in the tz database stands for the
4531.1Schristos   containing region, its pre-1970 data entries are often accurate for
4541.1Schristos   only a small subset of that region.  For example, <code>Europe/London</code>
4551.1Schristos   stands for the United Kingdom, but its pre-1847 times are valid
4561.1Schristos   only for locations that have London's exact meridian, and its 1847
4571.1Schristos   transition to GMT is known to be valid only for the L&amp;NW and the
4581.1Schristos   Caledonian railways.
4591.1Schristos  </li>
4601.1Schristos  <li>
4611.1Schristos   The tz database does not record the earliest time for which a zone's
4621.1Schristos   data entries are thereafter valid for every location in the region.
4631.1Schristos   For example, <code>Europe/London</code> is valid for all locations in its
4641.1Schristos   region after GMT was made the standard time, but the date of
4651.1Schristos   standardization (1880-08-02) is not in the tz database, other than
4661.1Schristos   in commentary.  For many zones the earliest time of validity is
4671.1Schristos   unknown.
4681.1Schristos  </li>
4691.1Schristos  <li>
4701.1Schristos   The tz database does not record a region's boundaries, and in many
4711.1Schristos   cases the boundaries are not known.  For example, the zone
4721.1Schristos   <code>America/Kentucky/Louisville</code> represents a region around
4731.1Schristos   the city of
4741.1Schristos   Louisville, the boundaries of which are unclear.
4751.1Schristos  </li>
4761.1Schristos  <li>
4771.1Schristos   Changes that are modeled as instantaneous transitions in the tz
4781.1Schristos   database were often spread out over hours, days, or even decades.
4791.1Schristos  </li>
4801.1Schristos  <li>
4811.1Schristos   Even if the time is specified by law, locations sometimes
4821.1Schristos   deliberately flout the law.
4831.1Schristos  </li>
4841.1Schristos  <li>
4851.1Schristos   Early timekeeping practices, even assuming perfect clocks, were
4861.1Schristos   often not specified to the accuracy that the tz database requires.
4871.1Schristos  </li>
4881.1Schristos  <li>
4891.1Schristos   Sometimes historical timekeeping was specified more precisely
4901.1Schristos   than what the tz database can handle.  For example, from 1909 to
4911.1Schristos   1937 Netherlands clocks were legally UT +00:19:32.13, but the tz
4921.1Schristos   database cannot represent the fractional second.
4931.1Schristos  </li>
4941.1Schristos  <li>
4951.1Schristos   Even when all the timestamp transitions recorded by the tz database
4961.1Schristos   are correct, the tz rules that generate them may not faithfully
4971.1Schristos   reflect the historical rules.  For example, from 1922 until World
4981.1Schristos   War II the UK moved clocks forward the day following the third
4991.1Schristos   Saturday in April unless that was Easter, in which case it moved
5001.1Schristos   clocks forward the previous Sunday.  Because the tz database has no
5011.1Schristos   way to specify Easter, these exceptional years are entered as
5021.1Schristos   separate tz Rule lines, even though the legal rules did not change.
5031.1Schristos  </li>
5041.1Schristos  <li>
5051.1Schristos   The tz database models pre-standard time using the proleptic Gregorian
5061.1Schristos   calendar and local mean time (LMT), but many people used other
5071.1Schristos   calendars and other timescales.  For example, the Roman Empire used
5081.1Schristos   the Julian calendar, and had 12 varying-length daytime hours with a
5091.1Schristos   non-hour-based system at night.
5101.1Schristos  </li>
5111.1Schristos  <li>
5121.1Schristos   Early clocks were less reliable, and data entries do not represent
5131.1Schristos   clock error.
5141.1Schristos  </li>
5151.1Schristos  <li>
5161.1Schristos   The tz database assumes Universal Time (UT) as an origin, even
5171.1Schristos   though UT is not standardized for older timestamps.  In the tz
5181.1Schristos   database commentary, UT denotes a family of time standards that
5191.1Schristos   includes Coordinated Universal Time (UTC) along with other variants
5201.1Schristos   such as UT1 and GMT, with days starting at midnight.  Although UT
5211.1Schristos   equals UTC for modern timestamps, UTC was not defined until 1960,
5221.1Schristos   so commentary uses the more-general abbreviation UT for timestamps
5231.1Schristos   that might predate 1960.  Since UT, UT1, etc. disagree slightly,
5241.1Schristos   and since pre-1972 UTC seconds varied in length, interpretation of
5251.1Schristos   older timestamps can be problematic when subsecond accuracy is
5261.1Schristos   needed.
5271.1Schristos  </li>
5281.1Schristos  <li>
5291.1Schristos   Civil time was not based on atomic time before 1972, and we don't
5301.1Schristos   know the history of earth's rotation accurately enough to map SI
5311.1Schristos   seconds to historical solar time to more than about one-hour
5321.1Schristos   accuracy.  See: Stephenson FR, Morrison LV, Hohenkerk CY.
5331.1Schristos   <a href="http://dx.doi.org/10.1098/rspa.2016.0404">Measurement
5341.1Schristos   of the Earth's rotation: 720 BC to AD 2015</a>.
5351.1Schristos   <cite>Proc Royal Soc A</cite>. 2016 Dec 7;472:20160404.
5361.1Schristos   Also see: Espenak F. <a
5371.1Schristos   href="https://eclipse.gsfc.nasa.gov/SEhelp/uncertainty2004.html">Uncertainty
5381.1Schristos   in Delta T (ΔT)</a>.
5391.1Schristos  </li>
5401.1Schristos  <li>
5411.1Schristos   The relationship between POSIX time (that is, UTC but ignoring leap
5421.1Schristos   seconds) and UTC is not agreed upon after 1972.  Although the POSIX
5431.1Schristos   clock officially stops during an inserted leap second, at least one
5441.1Schristos   proposed standard has it jumping back a second instead; and in
5451.1Schristos   practice POSIX clocks more typically either progress glacially during
5461.1Schristos   a leap second, or are slightly slowed while near a leap second.
5471.1Schristos  </li>
5481.1Schristos  <li>
5491.1Schristos   The tz database does not represent how uncertain its information is.
5501.1Schristos   Ideally it would contain information about when data entries are
5511.1Schristos   incomplete or dicey.  Partial temporal knowledge is a field of
5521.1Schristos   active research, though, and it's not clear how to apply it here.
5531.1Schristos  </li>
5541.1Schristos</ul>
5551.1Schristos<p>
5561.1SchristosIn short, many, perhaps most, of the tz database's pre-1970 and future
5571.1Schristostimestamps are either wrong or misleading.  Any attempt to pass the
5581.1Schristostz database off as the definition of time should be unacceptable to
5591.1Schristosanybody who cares about the facts.  In particular, the tz database's
5601.1SchristosLMT offsets should not be considered meaningful, and should not prompt
5611.1Schristoscreation of zones merely because two locations differ in LMT or
5621.1Schristostransitioned to standard time at different dates.
5631.1Schristos</p>
5641.1Schristos  </section>
5651.1Schristos
5661.1Schristos
5671.1Schristos  <section>
5681.1Schristos    <h2 id="functions">Time and date functions</h2>
5691.1Schristos<p>
5701.1SchristosThe tz code contains time and date functions that are upwards
5711.1Schristoscompatible with those of POSIX.
5721.1Schristos</p>
5731.1Schristos
5741.1Schristos<p>
5751.1SchristosPOSIX has the following properties and limitations.
5761.1Schristos</p>
5771.1Schristos<ul>
5781.1Schristos  <li>
5791.1Schristos    <p>
5801.1Schristos	In POSIX, time display in a process is controlled by the
5811.1Schristos	environment variable TZ.  Unfortunately, the POSIX TZ string takes
5821.1Schristos	a form that is hard to describe and is error-prone in practice.
5831.1Schristos	Also, POSIX TZ strings can't deal with other (for example, Israeli)
5841.1Schristos	daylight saving time rules, or situations where more than two
5851.1Schristos	time zone abbreviations are used in an area.
5861.1Schristos    </p>
5871.1Schristos    <p>
5881.1Schristos      The POSIX TZ string takes the following form:
5891.1Schristos    </p>
5901.1Schristos    <p>
5911.1Schristos      <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>]]]
5921.1Schristos    </p>
5931.1Schristos    <p>
5941.1Schristos	where:
5951.1Schristos    <dl>
5961.1Schristos      <dt><var>std</var> and <var>dst</var></dt><dd>
5971.1Schristos		are 3 or more characters specifying the standard
5981.1Schristos		and daylight saving time (DST) zone names.
5991.1Schristos		Starting with POSIX.1-2001, <var>std</var>
6001.1Schristos		and <var>dst</var> may also be
6011.1Schristos		in a quoted form like '<code>&lt;UTC+10&gt;</code>'; this allows
6021.1Schristos		"<code>+</code>" and "<code>-</code>" in the names.
6031.1Schristos      </dd>
6041.1Schristos      <dt><var>offset</var></dt><dd>
6051.1Schristos		is of the form
6061.1Schristos		'<code>[&plusmn;]<var>hh</var>:[<var>mm</var>[:<var>ss</var>]]</code>'
6071.1Schristos		and specifies the offset west of UT.  '<var>hh</var>'
6081.1Schristos		may be a single digit; 0&le;<var>hh</var>&le;24.
6091.1Schristos		The default DST offset is one hour ahead of standard time.
6101.1Schristos      </dd>
6111.1Schristos      <dt><var>date</var>[<code>/</code><var>time</var>]<code>,</code><var>date</var>[<code>/</code><var>time</var>]</dt><dd>
6121.1Schristos		specifies the beginning and end of DST.  If this is absent,
6131.1Schristos		the system supplies its own rules for DST, and these can
6141.1Schristos		differ from year to year; typically US DST rules are used.
6151.1Schristos      </dd>
6161.1Schristos      <dt><var>time</var></dt><dd>
6171.1Schristos		takes the form
6181.1Schristos		'<var>hh</var><code>:</code>[<var>mm</var>[<code>:</code><var>ss</var>]]'
6191.1Schristos		and defaults to 02:00.
6201.1Schristos		This is the same format as the offset, except that a
6211.1Schristos		leading '<code>+</code>' or '<code>-</code>' is not allowed.
6221.1Schristos      </dd>
6231.1Schristos      <dt><var>date</var></dt><dd>
6241.1Schristos		takes one of the following forms:
6251.1Schristos	<dl>
6261.1Schristos	  <dt>J<var>n</var> (1&le;<var>n</var>&le;365)</dt><dd>
6271.1Schristos			origin-1 day number not counting February 29
6281.1Schristos          </dd>
6291.1Schristos	  <dt><var>n</var> (0&le;<var>n</var>&le;365)</dt><dd>
6301.1Schristos			origin-0 day number counting February 29 if present
6311.1Schristos          </dd>
6321.1Schristos	  <dt><code>M</code><var>m</var><code>.</code><var>n</var><code>.</code><var>d</var> (0[Sunday]&le;<var>d</var>&le;6[Saturday], 1&le;<var>n</var>&le;5, 1&le;<var>m</var>&le;12)</dt><dd>
6331.1Schristos			for the <var>d</var>th day of
6341.1Schristos			week <var>n</var> of month <var>m</var> of the
6351.1Schristos			year, where week 1 is the first week in which
6361.1Schristos			day <var>d</var> appears, and '<code>5</code>'
6371.1Schristos			stands for the last week in which
6381.1Schristos			day <var>d</var> appears
6391.1Schristos			(which may be either the 4th or 5th week).
6401.1Schristos			Typically, this is the only useful form;
6411.1Schristos			the <var>n</var>
6421.1Schristos			and <code>J</code><var>n</var> forms are
6431.1Schristos			rarely used.
6441.1Schristos	  </dd>
6451.1Schristos</dl>
6461.1Schristos</dd>
6471.1Schristos</dl>
6481.1Schristos	Here is an example POSIX TZ string for New Zealand after 2007.
6491.1Schristos	It says that standard time (NZST) is 12 hours ahead of UTC,
6501.1Schristos	and that daylight saving time (NZDT) is observed from September's
6511.1Schristos	last Sunday at 02:00 until April's first Sunday at 03:00:
6521.1Schristos
6531.1Schristos        <pre><code>TZ='NZST-12NZDT,M9.5.0,M4.1.0/3'</code></pre>
6541.1Schristos
6551.1Schristos	This POSIX TZ string is hard to remember, and mishandles some
6561.1Schristos	timestamps before 2008.  With this package you can use this
6571.1Schristos	instead:
6581.1Schristos
6591.1Schristos	<pre><code>TZ='Pacific/Auckland'</code></pre>
6601.1Schristos  </li>
6611.1Schristos  <li>
6621.1Schristos	POSIX does not define the exact meaning of TZ values like
6631.1Schristos	"<code>EST5EDT</code>".
6641.1Schristos	Typically the current US DST rules are used to interpret such values,
6651.1Schristos	but this means that the US DST rules are compiled into each program
6661.1Schristos	that does time conversion.  This means that when US time conversion
6671.1Schristos	rules change (as in the United States in 1987), all programs that
6681.1Schristos	do time conversion must be recompiled to ensure proper results.
6691.1Schristos  </li>
6701.1Schristos  <li>
6711.1Schristos	The TZ environment variable is process-global, which makes it hard
6721.1Schristos	to write efficient, thread-safe applications that need access
6731.1Schristos	to multiple time zones.
6741.1Schristos  </li>
6751.1Schristos  <li>
6761.1Schristos	In POSIX, there's no tamper-proof way for a process to learn the
6771.1Schristos	system's best idea of local wall clock.  (This is important for
6781.1Schristos	applications that an administrator wants used only at certain
6791.1Schristos	times &ndash;
6801.1Schristos	without regard to whether the user has fiddled the TZ environment
6811.1Schristos	variable.  While an administrator can "do everything in UTC" to get
6821.1Schristos	around the problem, doing so is inconvenient and precludes handling
6831.1Schristos	daylight saving time shifts - as might be required to limit phone
6841.1Schristos	calls to off-peak hours.)
6851.1Schristos  </li>
6861.1Schristos  <li>
6871.1Schristos	POSIX provides no convenient and efficient way to determine the UT
6881.1Schristos	offset and time zone abbreviation of arbitrary timestamps,
6891.1Schristos	particularly for time zone settings that do not fit into the
6901.1Schristos	POSIX model.
6911.1Schristos  </li>
6921.1Schristos  <li>
6931.1Schristos	POSIX requires that systems ignore leap seconds.
6941.1Schristos  </li>
6951.1Schristos  <li>
6961.1Schristos	The tz code attempts to support all the <code>time_t</code>
6971.1Schristos	implementations allowed by POSIX.  The <code>time_t</code>
6981.1Schristos	type represents a nonnegative count of
6991.1Schristos	seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds.
7001.1Schristos	In practice, <code>time_t</code> is usually a signed 64- or
7011.1Schristos	32-bit integer; 32-bit signed <code>time_t</code> values stop
7021.1Schristos	working after 2038-01-19 03:14:07 UTC, so
7031.1Schristos	new implementations these days typically use a signed 64-bit integer.
7041.1Schristos	Unsigned 32-bit integers are used on one or two platforms,
7051.1Schristos	and 36-bit and 40-bit integers are also used occasionally.
7061.1Schristos	Although earlier POSIX versions allowed <code>time_t</code> to be a
7071.1Schristos	floating-point type, this was not supported by any practical
7081.1Schristos	systems, and POSIX.1-2013 and the tz code both
7091.1Schristos	require <code>time_t</code>
7101.1Schristos	to be an integer type.
7111.1Schristos  </li>
7121.1Schristos</ul>
7131.1Schristos<p>
7141.1SchristosThese are the extensions that have been made to the POSIX functions:
7151.1Schristos</p>
7161.1Schristos<ul>
7171.1Schristos  <li>
7181.1Schristos    <p>
7191.1Schristos	The TZ environment variable is used in generating the name of a file
7201.1Schristos	from which time zone information is read (or is interpreted a la
7211.1Schristos	POSIX); TZ is no longer constrained to be a three-letter time zone
7221.1Schristos	name followed by a number of hours and an optional three-letter
7231.1Schristos	daylight time zone name.  The daylight saving time rules to be used
7241.1Schristos	for a particular time zone are encoded in the time zone file;
7251.1Schristos	the format of the file allows U.S., Australian, and other rules to be
7261.1Schristos	encoded, and allows for situations where more than two time zone
7271.1Schristos	abbreviations are used.
7281.1Schristos    </p>
7291.1Schristos    <p>
7301.1Schristos	It was recognized that allowing the TZ environment variable to
7311.1Schristos	take on values such as '<code>America/New_York</code>' might
7321.1Schristos	cause "old" programs
7331.1Schristos	(that expect TZ to have a certain form) to operate incorrectly;
7341.1Schristos	consideration was given to using some other environment variable
7351.1Schristos	(for example, TIMEZONE) to hold the string used to generate the
7361.1Schristos	time zone information file name.  In the end, however, it was decided
7371.1Schristos	to continue using TZ: it is widely used for time zone purposes;
7381.1Schristos	separately maintaining both TZ and TIMEZONE seemed a nuisance;
7391.1Schristos	and systems where "new" forms of TZ might cause problems can simply
7401.1Schristos	use TZ values such as "<code>EST5EDT</code>" which can be used both by
7411.1Schristos	"new" programs (a la POSIX) and "old" programs (as zone names and
7421.1Schristos	offsets).
7431.1Schristos    </p>
7441.1Schristos</li>
7451.1Schristos<li>
7461.1Schristos	The code supports platforms with a UT offset member
7471.1Schristos	in <code>struct tm</code>,
7481.1Schristos	e.g., <code>tm_gmtoff</code>.
7491.1Schristos</li>
7501.1Schristos<li>
7511.1Schristos	The code supports platforms with a time zone abbreviation member in
7521.1Schristos	<code>struct tm</code>, e.g., <code>tm_zone</code>.
7531.1Schristos</li>
7541.1Schristos<li>
7551.1Schristos	Since the TZ environment variable can now be used to control time
7561.1Schristos	conversion, the <code>daylight</code>
7571.1Schristos	and <code>timezone</code> variables are no longer needed.
7581.1Schristos	(These variables are defined and set by <code>tzset</code>;
7591.1Schristos	however, their values will not be used
7601.1Schristos	by <code>localtime</code>.)
7611.1Schristos</li>
7621.1Schristos<li>
7631.1Schristos	Functions <code>tzalloc</code>, <code>tzfree</code>,
7641.1Schristos	<code>localtime_rz</code>, and <code>mktime_z</code> for
7651.1Schristos	more-efficient thread-safe applications that need to use
7661.1Schristos	multiple time zones.  The <code>tzalloc</code>
7671.1Schristos	and <code>tzfree</code> functions allocate and free objects of
7681.1Schristos	type <code>timezone_t</code>, and <code>localtime_rz</code>
7691.1Schristos	and <code>mktime_z</code> are like <code>localtime_r</code>
7701.1Schristos	and <code>mktime</code> with an extra
7711.1Schristos	<code>timezone_t</code> argument.  The functions were inspired
7721.1Schristos	by NetBSD.
7731.1Schristos</li>
7741.1Schristos<li>
7751.1Schristos	A function <code>tzsetwall</code> has been added to arrange
7761.1Schristos	for the system's
7771.1Schristos	best approximation to local wall clock time to be delivered by
7781.1Schristos	subsequent calls to <code>localtime</code>.  Source code for portable
7791.1Schristos	applications that "must" run on local wall clock time should call
7801.1Schristos	<code>tzsetwall</code>; if such code is moved to "old" systems that don't
7811.1Schristos	provide tzsetwall, you won't be able to generate an executable program.
7821.1Schristos	(These time zone functions also arrange for local wall clock time to be
7831.1Schristos	used if tzset is called &ndash; directly or indirectly &ndash;
7841.1Schristos	and there's no TZ
7851.1Schristos	environment variable; portable applications should not, however, rely
7861.1Schristos	on this behavior since it's not the way SVR2 systems behave.)
7871.1Schristos</li>
7881.1Schristos<li>
7891.1Schristos	Negative <code>time_t</code> values are supported, on systems
7901.1Schristos	where <code>time_t</code> is signed.
7911.1Schristos</li>
7921.1Schristos<li>
7931.1Schristos	These functions can account for leap seconds, thanks to Bradley White.
7941.1Schristos</li>
7951.1Schristos</ul>
7961.1Schristos<p>
7971.1SchristosPoints of interest to folks with other systems:
7981.1Schristos</p>
7991.1Schristos<ul>
8001.1Schristos  <li>
8011.1Schristos	Code compatible with this package is already part of many platforms,
8021.1Schristos	including GNU/Linux, Android, the BSDs, Chromium OS, Cygwin, AIX, iOS,
8031.1Schristos	BlackBery 10, macOS, Microsoft Windows, OpenVMS, and Solaris.
8041.1Schristos	On such hosts, the primary use of this package
8051.1Schristos	is to update obsolete time zone rule tables.
8061.1Schristos	To do this, you may need to compile the time zone compiler
8071.1Schristos	'<code>zic</code>' supplied with this package instead of using
8081.1Schristos	the system '<code>zic</code>', since the format
8091.1Schristos	of <code>zic</code>'s input is occasionally extended, and a
8101.1Schristos	platform may still be shipping an older <code>zic</code>.
8111.1Schristos  </li>
8121.1Schristos  <li>
8131.1Schristos	The UNIX Version 7 <code>timezone</code> function is not
8141.1Schristos	present in this package;
8151.1Schristos	it's impossible to reliably map timezone's arguments (a "minutes west
8161.1Schristos	of GMT" value and a "daylight saving time in effect" flag) to a
8171.1Schristos	time zone abbreviation, and we refuse to guess.
8181.1Schristos	Programs that in the past used the timezone function may now examine
8191.1Schristos	<code>localtime(&amp;clock)-&gt;tm_zone</code>
8201.1Schristos	(if <code>TM_ZONE</code> is defined) or
8211.1Schristos	<code>tzname[localtime(&amp;clock)-&gt;tm_isdst]</code>
8221.1Schristos	(if <code>HAVE_TZNAME</code> is defined)
8231.1Schristos	to learn the correct time zone abbreviation to use.
8241.1Schristos  </li>
8251.1Schristos  <li>
8261.1Schristos	The 4.2BSD <code>gettimeofday</code> function is not used in
8271.1Schristos	this package.
8281.1Schristos	This formerly let users obtain the current UTC offset and DST flag,
8291.1Schristos	but this functionality was removed in later versions of BSD.
8301.1Schristos  </li>
8311.1Schristos  <li>
8321.1Schristos	In SVR2, time conversion fails for near-minimum or near-maximum
8331.1Schristos	<code>time_t</code> values when doing conversions for places
8341.1Schristos	that don't use UT.
8351.1Schristos	This package takes care to do these conversions correctly.
8361.1Schristos	A comment in the source code tells how to get compatibly wrong
8371.1Schristos	results.
8381.1Schristos  </li>
8391.1Schristos</ul>
8401.1Schristos<p>
8411.1SchristosThe functions that are conditionally compiled
8421.1Schristosif <code>STD_INSPIRED</code> is defined
8431.1Schristosshould, at this point, be looked on primarily as food for thought.  They are
8441.1Schristosnot in any sense "standard compatible" &ndash; some are not, in fact,
8451.1Schristosspecified in <em>any</em> standard.  They do, however, represent responses of
8461.1Schristosvarious authors to
8471.1Schristosstandardization proposals.
8481.1Schristos</p>
8491.1Schristos
8501.1Schristos<p>
8511.1SchristosOther time conversion proposals, in particular the one developed by folks at
8521.1SchristosHewlett Packard, offer a wider selection of functions that provide capabilities
8531.1Schristosbeyond those provided here.  The absence of such functions from this package
8541.1Schristosis not meant to discourage the development, standardization, or use of such
8551.1Schristosfunctions.  Rather, their absence reflects the decision to make this package
8561.1Schristoscontain valid extensions to POSIX, to ensure its broad acceptability.  If
8571.1Schristosmore powerful time conversion functions can be standardized, so much the
8581.1Schristosbetter.
8591.1Schristos</p>
8601.1Schristos  </section>
8611.1Schristos
8621.1Schristos
8631.1Schristos  <section>
8641.1Schristos    <h2 id="stability">Interface stability</h2>
8651.1Schristos<p>
8661.1SchristosThe tz code and data supply the following interfaces:
8671.1Schristos</p>
8681.1Schristos<ul>
8691.1Schristos  <li>
8701.1Schristos   A set of zone names as per "<a href="#naming">Names of time zone
8711.1Schristos   rules</a>" above.
8721.1Schristos  </li>
8731.1Schristos  <li>
8741.1Schristos   Library functions described in "<a href="#functions">Time and date
8751.1Schristos   functions</a>" above.
8761.1Schristos  </li>
8771.1Schristos  <li>
8781.1Schristos   The programs <code>tzselect</code>, <code>zdump</code>,
8791.1Schristos   and <code>zic</code>, documented in their man pages.
8801.1Schristos  </li>
8811.1Schristos  <li>
8821.1Schristos   The format of <code>zic</code> input files, documented in
8831.1Schristos   the <code>zic</code> man page.
8841.1Schristos  </li>
8851.1Schristos  <li>
8861.1Schristos   The format of <code>zic</code> output files, documented in
8871.1Schristos   the <code>tzfile</code> man page.
8881.1Schristos  </li>
8891.1Schristos  <li>
8901.1Schristos   The format of zone table files, documented in <code>zone1970.tab</code>.
8911.1Schristos  </li>
8921.1Schristos  <li>
8931.1Schristos   The format of the country code file, documented in <code>iso3166.tab</code>.
8941.1Schristos  </li>
8951.1Schristos  <li>
8961.1Schristos   The version number of the code and data, as the first line of
8971.1Schristos   the text file '<code>version</code>' in each release.
8981.1Schristos  </li>
8991.1Schristos</ul>
9001.1Schristos<p>
9011.1SchristosInterface changes in a release attempt to preserve compatibility with
9021.1Schristosrecent releases.  For example, tz data files typically do not rely on
9031.1Schristosrecently-added <code>zic</code> features, so that users can run
9041.1Schristosolder <code>zic</code> versions to process newer data
9051.1Schristosfiles.  <a href="tz-link.htm">Sources for time zone and daylight
9061.1Schristossaving time data</a> describes how
9071.1Schristosreleases are tagged and distributed.
9081.1Schristos</p>
9091.1Schristos
9101.1Schristos<p>
9111.1SchristosInterfaces not listed above are less stable.  For example, users
9121.1Schristosshould not rely on particular UT offsets or abbreviations for
9131.1Schristostimestamps, as data entries are often based on guesswork and these
9141.1Schristosguesses may be corrected or improved.
9151.1Schristos</p>
9161.1Schristos  </section>
9171.1Schristos
9181.1Schristos
9191.1Schristos  <section>
9201.1Schristos    <h2 id="calendar">Calendrical issues</h2>
9211.1Schristos<p>
9221.1SchristosCalendrical issues are a bit out of scope for a time zone database,
9231.1Schristosbut they indicate the sort of problems that we would run into if we
9241.1Schristosextended the time zone database further into the past.  An excellent
9251.1Schristosresource in this area is Nachum Dershowitz and Edward M. Reingold,
9261.1Schristos<cite><a href="https://www.cs.tau.ac.il/~nachum/calendar-book/third-edition/">Calendrical
9271.1SchristosCalculations: Third Edition</a></cite>, Cambridge University Press (2008).
9281.1SchristosOther information and sources are given in the file '<samp>calendars</samp>'
9291.1Schristosin the tz distribution.  They sometimes disagree.
9301.1Schristos</p>
9311.1Schristos  </section>
9321.1Schristos
9331.1Schristos
9341.1Schristos  <section>
9351.1Schristos    <h2 id="planets">Time and time zones on other planets</h2>
9361.1Schristos<p>
9371.1SchristosSome people's work schedules use Mars time.  Jet Propulsion Laboratory
9381.1Schristos(JPL) coordinators have kept Mars time on and off at least since 1997
9391.1Schristosfor the Mars Pathfinder mission.  Some of their family members have
9401.1Schristosalso adapted to Mars time.  Dozens of special Mars watches were built
9411.1Schristosfor JPL workers who kept Mars time during the Mars Exploration
9421.1SchristosRovers mission (2004).  These timepieces look like normal Seikos and
9431.1SchristosCitizens but use Mars seconds rather than terrestrial seconds.
9441.1Schristos</p>
9451.1Schristos
9461.1Schristos<p>
9471.1SchristosA Mars solar day is called a "sol" and has a mean period equal to
9481.1Schristosabout 24 hours 39 minutes 35.244 seconds in terrestrial time.  It is
9491.1Schristosdivided into a conventional 24-hour clock, so each Mars second equals
9501.1Schristosabout 1.02749125 terrestrial seconds.
9511.1Schristos</p>
9521.1Schristos
9531.1Schristos<p>
9541.1SchristosThe prime meridian of Mars goes through the center of the crater
9551.1SchristosAiry-0, named in honor of the British astronomer who built the
9561.1SchristosGreenwich telescope that defines Earth's prime meridian.  Mean solar
9571.1Schristostime on the Mars prime meridian is called Mars Coordinated Time (MTC).
9581.1Schristos</p>
9591.1Schristos
9601.1Schristos<p>
9611.1SchristosEach landed mission on Mars has adopted a different reference for
9621.1Schristossolar time keeping, so there is no real standard for Mars time zones.
9631.1SchristosFor example, the Mars Exploration Rover project (2004) defined two
9641.1Schristostime zones "Local Solar Time A" and "Local Solar Time B" for its two
9651.1Schristosmissions, each zone designed so that its time equals local true solar
9661.1Schristostime at approximately the middle of the nominal mission.  Such a "time
9671.1Schristoszone" is not particularly suited for any application other than the
9681.1Schristosmission itself.
9691.1Schristos</p>
9701.1Schristos
9711.1Schristos<p>
9721.1SchristosMany calendars have been proposed for Mars, but none have achieved
9731.1Schristoswide acceptance.  Astronomers often use Mars Sol Date (MSD) which is a
9741.1Schristossequential count of Mars solar days elapsed since about 1873-12-29
9751.1Schristos12:00 GMT.
9761.1Schristos</p>
9771.1Schristos
9781.1Schristos<p>
9791.1SchristosIn our solar system, Mars is the planet with time and calendar most
9801.1Schristoslike Earth's.  On other planets, Sun-based time and calendars would
9811.1Schristoswork quite differently.  For example, although Mercury's sidereal
9821.1Schristosrotation period is 58.646 Earth days, Mercury revolves around the Sun
9831.1Schristosso rapidly that an observer on Mercury's equator would see a sunrise
9841.1Schristosonly every 175.97 Earth days, i.e., a Mercury year is 0.5 of a Mercury
9851.1Schristosday.  Venus is more complicated, partly because its rotation is
9861.1Schristosslightly retrograde: its year is 1.92 of its days.  Gas giants like
9871.1SchristosJupiter are trickier still, as their polar and equatorial regions
9881.1Schristosrotate at different rates, so that the length of a day depends on
9891.1Schristoslatitude.  This effect is most pronounced on Neptune, where the day is
9901.1Schristosabout 12 hours at the poles and 18 hours at the equator.
9911.1Schristos</p>
9921.1Schristos
9931.1Schristos<p>
9941.1SchristosAlthough the tz database does not support time on other planets, it is
9951.1Schristosdocumented here in the hopes that support will be added eventually.
9961.1Schristos</p>
9971.1Schristos
9981.1Schristos<p>
9991.1SchristosSources:
10001.1Schristos</p>
10011.1Schristos<ul>
10021.1Schristos  <li>
10031.1SchristosMichael Allison and Robert Schmunk,
10041.1Schristos"<a href="https://www.giss.nasa.gov/tools/mars24/help/notes.html">Technical
10051.1SchristosNotes on Mars Solar Time as Adopted by the Mars24 Sunclock</a>"
10061.1Schristos(2012-08-08).
10071.1Schristos  </li>
10081.1Schristos  <li>
10091.1SchristosJia-Rui Chong,
10101.1Schristos"<a href="http://articles.latimes.com/2004/jan/14/science/sci-marstime14">Workdays
10111.1SchristosFit for a Martian</a>", Los Angeles Times
10121.1Schristos(2004-01-14), pp A1, A20-A21.
10131.1Schristos  </li>
10141.1Schristos  <li>
10151.1SchristosTom Chmielewski,
10161.1Schristos"<a href="https://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/">Jet
10171.1SchristosLag Is Worse on Mars</a>", The Atlantic (2015-02-26)
10181.1Schristos  </li>
10191.1Schristos  <li>
10201.1SchristosMatt Williams,
10211.1Schristos"<a href="https://www.universetoday.com/37481/days-of-the-planets/">How
10221.1Schristoslong is a day on the other planets of the solar system?</a>"
10231.1Schristos(2017-04-27).
10241.1Schristos  </li>
10251.1Schristos</ul>
10261.1Schristos  </section>
10271.1Schristos
10281.1Schristos  <footer>
10291.1Schristos    <hr>
10301.1SchristosThis file is in the public domain, so clarified as of 2009-05-17 by
10311.1SchristosArthur David Olson.
10321.1Schristos  </footer>
10331.1Schristos</body>
10341.1Schristos</html>
1035