Home | History | Annotate | Line # | Download | only in time
theory.html revision 1.1
      1  1.1  christos <!DOCTYPE html>
      2  1.1  christos <html lang="en">
      3  1.1  christos <head>
      4  1.1  christos   <title>Theory and pragmatics of the tz code and data</title>
      5  1.1  christos   <meta charset="UTF-8">
      6  1.1  christos </head>
      7  1.1  christos 
      8  1.1  christos <!-- The somewhat-unusal indenting style in this file is intended to
      9  1.1  christos      shrink the output of the shell command 'diff Theory Theory.html',
     10  1.1  christos      where 'Theory' was the plain text file that this file is derived
     11  1.1  christos      from.  The 'Theory' file used leading white space to indent, and
     12  1.1  christos      when possible that indentation is preserved here.  Eventually we
     13  1.1  christos      may stop doing this and remove this comment.  -->
     14  1.1  christos 
     15  1.1  christos <body>
     16  1.1  christos   <h1>Theory and pragmatics of the tz code and data</h1>
     17  1.1  christos   <h3>Outline</h3>
     18  1.1  christos   <nav>
     19  1.1  christos     <ul>
     20  1.1  christos       <li><a href="#scope">Scope of the tz database</a></li>
     21  1.1  christos       <li><a href="#naming">Names of time zone rules</a></li>
     22  1.1  christos       <li><a href="#abbreviations">Time zone abbreviations</a></li>
     23  1.1  christos       <li><a href="#accuracy">Accuracy of the tz database</a></li>
     24  1.1  christos       <li><a href="#functions">Time and date functions</a></li>
     25  1.1  christos       <li><a href="#stability">Interface stability</a></li>
     26  1.1  christos       <li><a href="#calendar">Calendrical issues</a></li>
     27  1.1  christos       <li><a href="#planets">Time and time zones on other planets</a></li>
     28  1.1  christos     </ul>
     29  1.1  christos   </nav>
     30  1.1  christos 
     31  1.1  christos 
     32  1.1  christos   <section>
     33  1.1  christos     <h2 id="scope">Scope of the tz database</h2>
     34  1.1  christos <p>
     35  1.1  christos The tz database attempts to record the history and predicted future of
     36  1.1  christos all computer-based clocks that track civil time.  To represent this
     37  1.1  christos data, the world is partitioned into regions whose clocks all agree
     38  1.1  christos about timestamps that occur after the somewhat-arbitrary cutoff point
     39  1.1  christos of the POSIX Epoch (1970-01-01 00:00:00 UTC).  For each such region,
     40  1.1  christos the database records all known clock transitions, and labels the region
     41  1.1  christos with a notable location.  Although 1970 is a somewhat-arbitrary
     42  1.1  christos cutoff, there are significant challenges to moving the cutoff earlier
     43  1.1  christos even by a decade or two, due to the wide variety of local practices
     44  1.1  christos before computer timekeeping became prevalent.
     45  1.1  christos </p>
     46  1.1  christos 
     47  1.1  christos <p>
     48  1.1  christos Clock transitions before 1970 are recorded for each such location,
     49  1.1  christos because most systems support timestamps before 1970 and could
     50  1.1  christos misbehave if data entries were omitted for pre-1970 transitions.
     51  1.1  christos However, the database is not designed for and does not suffice for
     52  1.1  christos applications requiring accurate handling of all past times everywhere,
     53  1.1  christos as it would take far too much effort and guesswork to record all
     54  1.1  christos details of pre-1970 civil timekeeping.
     55  1.1  christos </p>
     56  1.1  christos 
     57  1.1  christos <p>
     58  1.1  christos As described below, reference source code for using the tz database is
     59  1.1  christos also available.  The tz code is upwards compatible with POSIX, an
     60  1.1  christos international standard for UNIX-like systems.  As of this writing, the
     61  1.1  christos current edition of POSIX is:
     62  1.1  christos   <a href="http://pubs.opengroup.org/onlinepubs/9699919799/">
     63  1.1  christos   The Open Group Base Specifications Issue 7</a>,
     64  1.1  christos   IEEE Std 1003.1-2008, 2016 Edition.
     65  1.1  christos </p>
     66  1.1  christos   </section>
     67  1.1  christos 
     68  1.1  christos 
     69  1.1  christos 
     70  1.1  christos   <section>
     71  1.1  christos     <h2 id="naming">Names of time zone rules</h2>
     72  1.1  christos <p>
     73  1.1  christos Each of the database's time zone rules has a unique name.
     74  1.1  christos Inexperienced users are not expected to select these names unaided.
     75  1.1  christos Distributors should provide documentation and/or a simple selection
     76  1.1  christos interface that explains the names; for one example, see the 'tzselect'
     77  1.1  christos program in the tz code.  The
     78  1.1  christos <a href="http://cldr.unicode.org/">Unicode Common Locale Data
     79  1.1  christos Repository</a> contains data that may be useful for other
     80  1.1  christos selection interfaces.
     81  1.1  christos </p>
     82  1.1  christos 
     83  1.1  christos <p>
     84  1.1  christos The time zone rule naming conventions attempt to strike a balance
     85  1.1  christos among the following goals:
     86  1.1  christos </p>
     87  1.1  christos <ul>
     88  1.1  christos   <li>
     89  1.1  christos    Uniquely identify every region where clocks have agreed since 1970.
     90  1.1  christos    This is essential for the intended use: static clocks keeping local
     91  1.1  christos    civil time.
     92  1.1  christos   </li>
     93  1.1  christos   <li>
     94  1.1  christos    Indicate to experts where that region is.
     95  1.1  christos   </li>
     96  1.1  christos   <li>
     97  1.1  christos    Be robust in the presence of political changes.  For example, names
     98  1.1  christos    of countries are ordinarily not used, to avoid incompatibilities
     99  1.1  christos    when countries change their name (e.g. Zaire&rarr;Congo) or when
    100  1.1  christos    locations change countries (e.g. Hong Kong from UK colony to
    101  1.1  christos    China).
    102  1.1  christos   </li>
    103  1.1  christos   <li>
    104  1.1  christos    Be portable to a wide variety of implementations.
    105  1.1  christos   </li>
    106  1.1  christos   <li>
    107  1.1  christos    Use a consistent naming conventions over the entire world.
    108  1.1  christos   </li>
    109  1.1  christos </ul>
    110  1.1  christos <p>
    111  1.1  christos Names normally have the
    112  1.1  christos form <var>AREA</var><code>/</code><var>LOCATION</var>,
    113  1.1  christos where <var>AREA</var> is the name of a continent or ocean,
    114  1.1  christos and <var>LOCATION</var> is the name of a specific
    115  1.1  christos location within that region.  North and South America share the same
    116  1.1  christos area, '<code>America</code>'.  Typical names are
    117  1.1  christos '<code>Africa/Cairo</code>', '<code>America/New_York</code>', and
    118  1.1  christos '<code>Pacific/Honolulu</code>'.
    119  1.1  christos </p>
    120  1.1  christos 
    121  1.1  christos <p>
    122  1.1  christos Here are the general rules used for choosing location names,
    123  1.1  christos in decreasing order of importance:
    124  1.1  christos </p>
    125  1.1  christos <ul>
    126  1.1  christos   <li>
    127  1.1  christos 	Use only valid POSIX file name components (i.e., the parts of
    128  1.1  christos 		names other than '<code>/</code>').  Do not use the file name
    129  1.1  christos 		components '<code>.</code>' and '<code>..</code>'.
    130  1.1  christos 		Within a file name component,
    131  1.1  christos 		use only ASCII letters, '<code>.</code>',
    132  1.1  christos 		'<code>-</code>' and '<code>_</code>'.  Do not use
    133  1.1  christos 		digits, as that might create an ambiguity with POSIX
    134  1.1  christos 		TZ strings.  A file name component must not exceed 14
    135  1.1  christos 		characters or start with '<code>-</code>'.  E.g.,
    136  1.1  christos 		prefer '<code>Brunei</code>' to
    137  1.1  christos 		'<code>Bandar_Seri_Begawan</code>'.  Exceptions: see
    138  1.1  christos 		the discussion
    139  1.1  christos 		of legacy names below.
    140  1.1  christos   </li>
    141  1.1  christos   <li>
    142  1.1  christos 	A name must not be empty, or contain '<code>//</code>', or
    143  1.1  christos 	start or end with '<code>/</code>'.
    144  1.1  christos   </li>
    145  1.1  christos   <li>
    146  1.1  christos 	Do not use names that differ only in case.  Although the reference
    147  1.1  christos 		implementation is case-sensitive, some other implementations
    148  1.1  christos 		are not, and they would mishandle names differing only in case.
    149  1.1  christos   </li>
    150  1.1  christos   <li>
    151  1.1  christos 	If one name <var>A</var> is an initial prefix of another
    152  1.1  christos 		name <var>AB</var> (ignoring case), then <var>B</var>
    153  1.1  christos 		must not start with '<code>/</code>', as a
    154  1.1  christos 		regular file cannot have
    155  1.1  christos 		the same name as a directory in POSIX.  For example,
    156  1.1  christos 		'<code>America/New_York</code>' precludes
    157  1.1  christos 		'<code>America/New_York/Bronx</code>'.
    158  1.1  christos   </li>
    159  1.1  christos   <li>
    160  1.1  christos 	Uninhabited regions like the North Pole and Bouvet Island
    161  1.1  christos 		do not need locations, since local time is not defined there.
    162  1.1  christos   </li>
    163  1.1  christos   <li>
    164  1.1  christos 	There should typically be at least one name for each ISO 3166-1
    165  1.1  christos 		officially assigned two-letter code for an inhabited country
    166  1.1  christos 		or territory.
    167  1.1  christos   </li>
    168  1.1  christos   <li>
    169  1.1  christos 	If all the clocks in a region have agreed since 1970,
    170  1.1  christos 		don't bother to include more than one location
    171  1.1  christos 		even if subregions' clocks disagreed before 1970.
    172  1.1  christos 		Otherwise these tables would become annoyingly large.
    173  1.1  christos   </li>
    174  1.1  christos   <li>
    175  1.1  christos 	If a name is ambiguous, use a less ambiguous alternative;
    176  1.1  christos 		e.g. many cities are named San Jos and Georgetown, so
    177  1.1  christos 		prefer '<code>Costa_Rica</code>' to '<code>San_Jose</code>' and '<code>Guyana</code>' to '<code>Georgetown</code>'.
    178  1.1  christos   </li>
    179  1.1  christos   <li>
    180  1.1  christos 	Keep locations compact.  Use cities or small islands, not countries
    181  1.1  christos 		or regions, so that any future time zone changes do not split
    182  1.1  christos 		locations into different time zones.  E.g. prefer
    183  1.1  christos 		'<code>Paris</code>' to '<code>France</code>', since
    184  1.1  christos 		France has had multiple time zones.
    185  1.1  christos   </li>
    186  1.1  christos   <li>
    187  1.1  christos 	Use mainstream English spelling, e.g. prefer
    188  1.1  christos 		'<code>Rome</code>' to '<code>Roma</code>', and prefer
    189  1.1  christos 		'<code>Athens</code>' to the Greek
    190  1.1  christos 		'<code></code>' or the Romanized
    191  1.1  christos 		'<code>Athna</code>'.
    192  1.1  christos 		The POSIX file name restrictions encourage this rule.
    193  1.1  christos   </li>
    194  1.1  christos   <li>
    195  1.1  christos 	Use the most populous among locations in a zone,
    196  1.1  christos 		e.g. prefer '<code>Shanghai</code>' to
    197  1.1  christos 		'<code>Beijing</code>'.  Among locations with
    198  1.1  christos 		similar populations, pick the best-known location,
    199  1.1  christos 		e.g. prefer '<code>Rome</code>' to '<code>Milan</code>'.
    200  1.1  christos   </li>
    201  1.1  christos   <li>
    202  1.1  christos 	Use the singular form, e.g. prefer '<code>Canary</code>' to '<code>Canaries</code>'.
    203  1.1  christos   </li>
    204  1.1  christos   <li>
    205  1.1  christos 	Omit common suffixes like '<code>_Islands</code>' and
    206  1.1  christos 		'<code>_City</code>', unless that would lead to
    207  1.1  christos 		ambiguity.  E.g. prefer '<code>Cayman</code>' to
    208  1.1  christos 		'<code>Cayman_Islands</code>' and
    209  1.1  christos 		'<code>Guatemala</code>' to
    210  1.1  christos 		'<code>Guatemala_City</code>', but prefer
    211  1.1  christos 		'<code>Mexico_City</code>' to '<code>Mexico</code>'
    212  1.1  christos 		because the country
    213  1.1  christos 		of Mexico has several time zones.
    214  1.1  christos   </li>
    215  1.1  christos   <li>
    216  1.1  christos 	Use '<code>_</code>' to represent a space.
    217  1.1  christos   </li>
    218  1.1  christos   <li>
    219  1.1  christos 	Omit '<code>.</code>' from abbreviations in names, e.g. prefer
    220  1.1  christos 		'<code>St_Helena</code>' to '<code>St._Helena</code>'.
    221  1.1  christos   </li>
    222  1.1  christos   <li>
    223  1.1  christos 	Do not change established names if they only marginally
    224  1.1  christos 		violate the above rules.  For example, don't change
    225  1.1  christos 		the existing name '<code>Rome</code>' to
    226  1.1  christos 		'<code>Milan</code>' merely because
    227  1.1  christos 		Milan's population has grown to be somewhat greater
    228  1.1  christos 		than Rome's.
    229  1.1  christos   </li>
    230  1.1  christos   <li>
    231  1.1  christos 	If a name is changed, put its old spelling in the
    232  1.1  christos 		'<code>backward</code>' file.
    233  1.1  christos 		This means old spellings will continue to work.
    234  1.1  christos   </li>
    235  1.1  christos </ul>
    236  1.1  christos 
    237  1.1  christos <p>
    238  1.1  christos The file '<code>zone1970.tab</code>' lists geographical locations used
    239  1.1  christos to name time
    240  1.1  christos zone rules.  It is intended to be an exhaustive list of names for
    241  1.1  christos geographic regions as described above; this is a subset of the names
    242  1.1  christos in the data.  Although a '<code>zone1970.tab</code>' location's longitude
    243  1.1  christos corresponds to its LMT offset with one hour for every 15 degrees east
    244  1.1  christos longitude, this relationship is not exact.
    245  1.1  christos </p>
    246  1.1  christos 
    247  1.1  christos <p>
    248  1.1  christos Older versions of this package used a different naming scheme,
    249  1.1  christos and these older names are still supported.
    250  1.1  christos See the file '<code>backward</code>' for most of these older names
    251  1.1  christos (e.g., '<code>US/Eastern</code>' instead of '<code>America/New_York</code>').
    252  1.1  christos The other old-fashioned names still supported are
    253  1.1  christos '<code>WET</code>', '<code>CET</code>', '<code>MET</code>', and '<code>EET</code>' (see the file '<code>europe</code>').
    254  1.1  christos </p>
    255  1.1  christos 
    256  1.1  christos <p>
    257  1.1  christos Older versions of this package defined legacy names that are
    258  1.1  christos incompatible with the first rule of location names, but which are
    259  1.1  christos still supported.  These legacy names are mostly defined in the file
    260  1.1  christos '<code>etcetera</code>'.  Also, the file '<code>backward</code>' defines the legacy names
    261  1.1  christos '<code>GMT0</code>', '<code>GMT-0</code>' and '<code>GMT+0</code>', and the file '<code>northamerica</code>' defines the
    262  1.1  christos legacy names '<code>EST5EDT</code>', '<code>CST6CDT</code>', '<code>MST7MDT</code>', and '<code>PST8PDT</code>'.
    263  1.1  christos </p>
    264  1.1  christos 
    265  1.1  christos <p>
    266  1.1  christos Excluding '<code>backward</code>' should not affect the other data.  If
    267  1.1  christos '<code>backward</code>' is excluded, excluding '<code>etcetera</code>' should not affect the
    268  1.1  christos remaining data.
    269  1.1  christos </p>
    270  1.1  christos 
    271  1.1  christos 
    272  1.1  christos   </section>
    273  1.1  christos   <section>
    274  1.1  christos     <h2 id="abbreviations">Time zone abbreviations</h2>
    275  1.1  christos <p>
    276  1.1  christos When this package is installed, it generates time zone abbreviations
    277  1.1  christos like '<code>EST</code>' to be compatible with human tradition and POSIX.
    278  1.1  christos Here are the general rules used for choosing time zone abbreviations,
    279  1.1  christos in decreasing order of importance:
    280  1.1  christos <ul>
    281  1.1  christos   <li>
    282  1.1  christos 	Use three or more characters that are ASCII alphanumerics or
    283  1.1  christos 		'<code>+</code>' or '<code>-</code>'.
    284  1.1  christos 		Previous editions of this database also used characters like
    285  1.1  christos 		'<code> </code>' and '<code>?</code>', but these
    286  1.1  christos 		characters have a special meaning to
    287  1.1  christos 		the shell and cause commands like
    288  1.1  christos 			'<code>set `date`</code>'
    289  1.1  christos 		to have unexpected effects.
    290  1.1  christos 		Previous editions of this rule required upper-case letters,
    291  1.1  christos 		but the Congressman who introduced Chamorro Standard Time
    292  1.1  christos 		preferred "ChST", so lower-case letters are now allowed.
    293  1.1  christos 		Also, POSIX from 2001 on relaxed the rule to allow
    294  1.1  christos 		'<code>-</code>', '<code>+</code>',
    295  1.1  christos 		and alphanumeric characters from the portable character set
    296  1.1  christos 		in the current locale.  In practice ASCII alphanumerics and
    297  1.1  christos 		'<code>+</code>' and '<code>-</code>' are safe in all locales.
    298  1.1  christos 
    299  1.1  christos 		In other words, in the C locale the POSIX extended regular
    300  1.1  christos 		expression <code>[-+[:alnum:]]{3,}</code> should match
    301  1.1  christos 		the abbreviation.
    302  1.1  christos 		This guarantees that all abbreviations could have been
    303  1.1  christos 		specified by a POSIX TZ string.
    304  1.1  christos   </li>
    305  1.1  christos   <li>
    306  1.1  christos 	Use abbreviations that are in common use among English-speakers,
    307  1.1  christos 		e.g. 'EST' for Eastern Standard Time in North America.
    308  1.1  christos 		We assume that applications translate them to other languages
    309  1.1  christos 		as part of the normal localization process; for example,
    310  1.1  christos 		a French application might translate 'EST' to 'HNE'.
    311  1.1  christos   </li>
    312  1.1  christos   <li>
    313  1.1  christos 	For zones whose times are taken from a city's longitude, use the
    314  1.1  christos 		traditional <var>x</var>MT notation, e.g. 'PMT' for
    315  1.1  christos 		Paris Mean Time.
    316  1.1  christos 		The only name like this in current use is 'GMT'.
    317  1.1  christos   </li>
    318  1.1  christos   <li>
    319  1.1  christos 	Use 'LMT' for local mean time of locations before the introduction
    320  1.1  christos 		of standard time; see "<a href="#scope">Scope of the
    321  1.1  christos 		tz database</a>".
    322  1.1  christos   </li>
    323  1.1  christos   <li>
    324  1.1  christos 	If there is no common English abbreviation, use numeric offsets like
    325  1.1  christos 		<code>-</code>05 and <code>+</code>0830 that are
    326  1.1  christos 		generated by zic's <code>%z</code> notation.
    327  1.1  christos   </li>
    328  1.1  christos   <li>
    329  1.1  christos 	Use current abbreviations for older timestamps to avoid confusion.
    330  1.1  christos 		For example, in 1910 a common English abbreviation for UT +01
    331  1.1  christos 		in central Europe was 'MEZ' (short for both "Middle European
    332  1.1  christos 		Zone" and for "Mitteleuropische Zeit" in German).  Nowadays
    333  1.1  christos 		'CET' ("Central European Time") is more common in English, and
    334  1.1  christos 		the database uses 'CET' even for circa-1910 timestamps as this
    335  1.1  christos 		is less confusing for modern users and avoids the need for
    336  1.1  christos 		determining when 'CET' supplanted 'MEZ' in common usage.
    337  1.1  christos   </li>
    338  1.1  christos   <li>
    339  1.1  christos 	Use a consistent style in a zone's history.  For example, if a zone's
    340  1.1  christos 		history tends to use numeric abbreviations and a particular
    341  1.1  christos 		entry could go either way, use a numeric abbreviation.
    342  1.1  christos   </li>
    343  1.1  christos </ul>
    344  1.1  christos     [The remaining guidelines predate the introduction of <code>%z</code>.
    345  1.1  christos     They are problematic as they mean tz data entries invent
    346  1.1  christos     notation rather than record it.  These guidelines are now
    347  1.1  christos     deprecated and the plan is to gradually move to <code>%z</code> for
    348  1.1  christos     inhabited locations and to "<code>-</code>00" for uninhabited locations.]
    349  1.1  christos <ul>
    350  1.1  christos   <li>
    351  1.1  christos 	If there is no common English abbreviation, abbreviate the English
    352  1.1  christos 		translation of the usual phrase used by native speakers.
    353  1.1  christos 		If this is not available or is a phrase mentioning the country
    354  1.1  christos 		(e.g. "Cape Verde Time"), then:
    355  1.1  christos 	<ul>
    356  1.1  christos 	  <li>
    357  1.1  christos 		When a country is identified with a single or principal zone,
    358  1.1  christos 			append 'T' to the country's ISO	code, e.g. 'CVT' for
    359  1.1  christos 			Cape Verde Time.  For summer time append 'ST';
    360  1.1  christos 			for double summer time append 'DST'; etc.
    361  1.1  christos 	  </li>
    362  1.1  christos 	  <li>
    363  1.1  christos 		Otherwise, take the first three letters of an English place
    364  1.1  christos 			name identifying each zone and append 'T', 'ST', etc.
    365  1.1  christos 			as before; e.g. 'CHAST' for CHAtham Summer Time.
    366  1.1  christos 	  </li>
    367  1.1  christos 	</ul>
    368  1.1  christos   </li>
    369  1.1  christos   <li>
    370  1.1  christos 	Use UT (with time zone abbreviation '<code>-</code>00') for
    371  1.1  christos 		locations while uninhabited.  The leading
    372  1.1  christos 		'<code>-</code>' is a flag that the time
    373  1.1  christos 		zone is in some sense undefined; this notation is
    374  1.1  christos 		derived from Internet RFC 3339.
    375  1.1  christos   </li>
    376  1.1  christos </ul>
    377  1.1  christos <p>
    378  1.1  christos Application writers should note that these abbreviations are ambiguous
    379  1.1  christos in practice: e.g. 'CST' has a different meaning in China than
    380  1.1  christos it does in the United States.  In new applications, it's often better
    381  1.1  christos to use numeric UT offsets like '<code>-</code>0600' instead of time zone
    382  1.1  christos abbreviations like 'CST'; this avoids the ambiguity.
    383  1.1  christos </p>
    384  1.1  christos   </section>
    385  1.1  christos 
    386  1.1  christos 
    387  1.1  christos   <section>
    388  1.1  christos     <h2 id="accuracy">Accuracy of the tz database</h2>
    389  1.1  christos <p>
    390  1.1  christos The tz database is not authoritative, and it surely has errors.
    391  1.1  christos Corrections are welcome and encouraged; see the file CONTRIBUTING.
    392  1.1  christos Users requiring authoritative data should consult national standards
    393  1.1  christos bodies and the references cited in the database's comments.
    394  1.1  christos </p>
    395  1.1  christos 
    396  1.1  christos <p>
    397  1.1  christos Errors in the tz database arise from many sources:
    398  1.1  christos </p>
    399  1.1  christos <ul>
    400  1.1  christos   <li>
    401  1.1  christos    The tz database predicts future timestamps, and current predictions
    402  1.1  christos    will be incorrect after future governments change the rules.
    403  1.1  christos    For example, if today someone schedules a meeting for 13:00 next
    404  1.1  christos    October 1, Casablanca time, and tomorrow Morocco changes its
    405  1.1  christos    daylight saving rules, software can mess up after the rule change
    406  1.1  christos    if it blithely relies on conversions made before the change.
    407  1.1  christos   </li>
    408  1.1  christos   <li>
    409  1.1  christos    The pre-1970 entries in this database cover only a tiny sliver of how
    410  1.1  christos    clocks actually behaved; the vast majority of the necessary
    411  1.1  christos    information was lost or never recorded.  Thousands more zones would
    412  1.1  christos    be needed if the tz database's scope were extended to cover even
    413  1.1  christos    just the known or guessed history of standard time; for example,
    414  1.1  christos    the current single entry for France would need to split into dozens
    415  1.1  christos    of entries, perhaps hundreds.  And in most of the world even this
    416  1.1  christos    approach would be misleading due to widespread disagreement or
    417  1.1  christos    indifference about what times should be observed.  In her 2015 book
    418  1.1  christos    <cite>The Global Transformation of Time, 1870-1950</cite>, Vanessa Ogle writes
    419  1.1  christos    "Outside of Europe and North America there was no system of time
    420  1.1  christos    zones at all, often not even a stable landscape of mean times,
    421  1.1  christos    prior to the middle decades of the twentieth century".  See:
    422  1.1  christos    Timothy Shenk, <a
    423  1.1  christos    href="https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle">Booked:
    424  1.1  christos    A Global History of Time</a>. <cite>Dissent</cite> 2015-12-17.
    425  1.1  christos   </li>
    426  1.1  christos   <li>
    427  1.1  christos    Most of the pre-1970 data entries come from unreliable sources, often
    428  1.1  christos    astrology books that lack citations and whose compilers evidently
    429  1.1  christos    invented entries when the true facts were unknown, without
    430  1.1  christos    reporting which entries were known and which were invented.
    431  1.1  christos    These books often contradict each other or give implausible entries,
    432  1.1  christos    and on the rare occasions when they are checked they are
    433  1.1  christos    typically found to be incorrect.
    434  1.1  christos   </li>
    435  1.1  christos   <li>
    436  1.1  christos    For the UK the tz database relies on years of first-class work done by
    437  1.1  christos    Joseph Myers and others; see
    438  1.1  christos    "<a href="https://www.polyomino.org.uk/british-time/">History of
    439  1.1  christos    legal time in Britain</a>".
    440  1.1  christos    Other countries are not done nearly as well.
    441  1.1  christos   </li>
    442  1.1  christos   <li>
    443  1.1  christos    Sometimes, different people in the same city would maintain clocks
    444  1.1  christos    that differed significantly.  Railway time was used by railroad
    445  1.1  christos    companies (which did not always agree with each other),
    446  1.1  christos    church-clock time was used for birth certificates, etc.
    447  1.1  christos    Often this was merely common practice, but sometimes it was set by law.
    448  1.1  christos    For example, from 1891 to 1911 the UT offset in France was legally
    449  1.1  christos    0:09:21 outside train stations and 0:04:21 inside.
    450  1.1  christos   </li>
    451  1.1  christos   <li>
    452  1.1  christos    Although a named location in the tz database stands for the
    453  1.1  christos    containing region, its pre-1970 data entries are often accurate for
    454  1.1  christos    only a small subset of that region.  For example, <code>Europe/London</code>
    455  1.1  christos    stands for the United Kingdom, but its pre-1847 times are valid
    456  1.1  christos    only for locations that have London's exact meridian, and its 1847
    457  1.1  christos    transition to GMT is known to be valid only for the L&amp;NW and the
    458  1.1  christos    Caledonian railways.
    459  1.1  christos   </li>
    460  1.1  christos   <li>
    461  1.1  christos    The tz database does not record the earliest time for which a zone's
    462  1.1  christos    data entries are thereafter valid for every location in the region.
    463  1.1  christos    For example, <code>Europe/London</code> is valid for all locations in its
    464  1.1  christos    region after GMT was made the standard time, but the date of
    465  1.1  christos    standardization (1880-08-02) is not in the tz database, other than
    466  1.1  christos    in commentary.  For many zones the earliest time of validity is
    467  1.1  christos    unknown.
    468  1.1  christos   </li>
    469  1.1  christos   <li>
    470  1.1  christos    The tz database does not record a region's boundaries, and in many
    471  1.1  christos    cases the boundaries are not known.  For example, the zone
    472  1.1  christos    <code>America/Kentucky/Louisville</code> represents a region around
    473  1.1  christos    the city of
    474  1.1  christos    Louisville, the boundaries of which are unclear.
    475  1.1  christos   </li>
    476  1.1  christos   <li>
    477  1.1  christos    Changes that are modeled as instantaneous transitions in the tz
    478  1.1  christos    database were often spread out over hours, days, or even decades.
    479  1.1  christos   </li>
    480  1.1  christos   <li>
    481  1.1  christos    Even if the time is specified by law, locations sometimes
    482  1.1  christos    deliberately flout the law.
    483  1.1  christos   </li>
    484  1.1  christos   <li>
    485  1.1  christos    Early timekeeping practices, even assuming perfect clocks, were
    486  1.1  christos    often not specified to the accuracy that the tz database requires.
    487  1.1  christos   </li>
    488  1.1  christos   <li>
    489  1.1  christos    Sometimes historical timekeeping was specified more precisely
    490  1.1  christos    than what the tz database can handle.  For example, from 1909 to
    491  1.1  christos    1937 Netherlands clocks were legally UT +00:19:32.13, but the tz
    492  1.1  christos    database cannot represent the fractional second.
    493  1.1  christos   </li>
    494  1.1  christos   <li>
    495  1.1  christos    Even when all the timestamp transitions recorded by the tz database
    496  1.1  christos    are correct, the tz rules that generate them may not faithfully
    497  1.1  christos    reflect the historical rules.  For example, from 1922 until World
    498  1.1  christos    War II the UK moved clocks forward the day following the third
    499  1.1  christos    Saturday in April unless that was Easter, in which case it moved
    500  1.1  christos    clocks forward the previous Sunday.  Because the tz database has no
    501  1.1  christos    way to specify Easter, these exceptional years are entered as
    502  1.1  christos    separate tz Rule lines, even though the legal rules did not change.
    503  1.1  christos   </li>
    504  1.1  christos   <li>
    505  1.1  christos    The tz database models pre-standard time using the proleptic Gregorian
    506  1.1  christos    calendar and local mean time (LMT), but many people used other
    507  1.1  christos    calendars and other timescales.  For example, the Roman Empire used
    508  1.1  christos    the Julian calendar, and had 12 varying-length daytime hours with a
    509  1.1  christos    non-hour-based system at night.
    510  1.1  christos   </li>
    511  1.1  christos   <li>
    512  1.1  christos    Early clocks were less reliable, and data entries do not represent
    513  1.1  christos    clock error.
    514  1.1  christos   </li>
    515  1.1  christos   <li>
    516  1.1  christos    The tz database assumes Universal Time (UT) as an origin, even
    517  1.1  christos    though UT is not standardized for older timestamps.  In the tz
    518  1.1  christos    database commentary, UT denotes a family of time standards that
    519  1.1  christos    includes Coordinated Universal Time (UTC) along with other variants
    520  1.1  christos    such as UT1 and GMT, with days starting at midnight.  Although UT
    521  1.1  christos    equals UTC for modern timestamps, UTC was not defined until 1960,
    522  1.1  christos    so commentary uses the more-general abbreviation UT for timestamps
    523  1.1  christos    that might predate 1960.  Since UT, UT1, etc. disagree slightly,
    524  1.1  christos    and since pre-1972 UTC seconds varied in length, interpretation of
    525  1.1  christos    older timestamps can be problematic when subsecond accuracy is
    526  1.1  christos    needed.
    527  1.1  christos   </li>
    528  1.1  christos   <li>
    529  1.1  christos    Civil time was not based on atomic time before 1972, and we don't
    530  1.1  christos    know the history of earth's rotation accurately enough to map SI
    531  1.1  christos    seconds to historical solar time to more than about one-hour
    532  1.1  christos    accuracy.  See: Stephenson FR, Morrison LV, Hohenkerk CY.
    533  1.1  christos    <a href="http://dx.doi.org/10.1098/rspa.2016.0404">Measurement
    534  1.1  christos    of the Earth's rotation: 720 BC to AD 2015</a>.
    535  1.1  christos    <cite>Proc Royal Soc A</cite>. 2016 Dec 7;472:20160404.
    536  1.1  christos    Also see: Espenak F. <a
    537  1.1  christos    href="https://eclipse.gsfc.nasa.gov/SEhelp/uncertainty2004.html">Uncertainty
    538  1.1  christos    in Delta T (T)</a>.
    539  1.1  christos   </li>
    540  1.1  christos   <li>
    541  1.1  christos    The relationship between POSIX time (that is, UTC but ignoring leap
    542  1.1  christos    seconds) and UTC is not agreed upon after 1972.  Although the POSIX
    543  1.1  christos    clock officially stops during an inserted leap second, at least one
    544  1.1  christos    proposed standard has it jumping back a second instead; and in
    545  1.1  christos    practice POSIX clocks more typically either progress glacially during
    546  1.1  christos    a leap second, or are slightly slowed while near a leap second.
    547  1.1  christos   </li>
    548  1.1  christos   <li>
    549  1.1  christos    The tz database does not represent how uncertain its information is.
    550  1.1  christos    Ideally it would contain information about when data entries are
    551  1.1  christos    incomplete or dicey.  Partial temporal knowledge is a field of
    552  1.1  christos    active research, though, and it's not clear how to apply it here.
    553  1.1  christos   </li>
    554  1.1  christos </ul>
    555  1.1  christos <p>
    556  1.1  christos In short, many, perhaps most, of the tz database's pre-1970 and future
    557  1.1  christos timestamps are either wrong or misleading.  Any attempt to pass the
    558  1.1  christos tz database off as the definition of time should be unacceptable to
    559  1.1  christos anybody who cares about the facts.  In particular, the tz database's
    560  1.1  christos LMT offsets should not be considered meaningful, and should not prompt
    561  1.1  christos creation of zones merely because two locations differ in LMT or
    562  1.1  christos transitioned to standard time at different dates.
    563  1.1  christos </p>
    564  1.1  christos   </section>
    565  1.1  christos 
    566  1.1  christos 
    567  1.1  christos   <section>
    568  1.1  christos     <h2 id="functions">Time and date functions</h2>
    569  1.1  christos <p>
    570  1.1  christos The tz code contains time and date functions that are upwards
    571  1.1  christos compatible with those of POSIX.
    572  1.1  christos </p>
    573  1.1  christos 
    574  1.1  christos <p>
    575  1.1  christos POSIX has the following properties and limitations.
    576  1.1  christos </p>
    577  1.1  christos <ul>
    578  1.1  christos   <li>
    579  1.1  christos     <p>
    580  1.1  christos 	In POSIX, time display in a process is controlled by the
    581  1.1  christos 	environment variable TZ.  Unfortunately, the POSIX TZ string takes
    582  1.1  christos 	a form that is hard to describe and is error-prone in practice.
    583  1.1  christos 	Also, POSIX TZ strings can't deal with other (for example, Israeli)
    584  1.1  christos 	daylight saving time rules, or situations where more than two
    585  1.1  christos 	time zone abbreviations are used in an area.
    586  1.1  christos     </p>
    587  1.1  christos     <p>
    588  1.1  christos       The POSIX TZ string takes the following form:
    589  1.1  christos     </p>
    590  1.1  christos     <p>
    591  1.1  christos       <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>]]]
    592  1.1  christos     </p>
    593  1.1  christos     <p>
    594  1.1  christos 	where:
    595  1.1  christos     <dl>
    596  1.1  christos       <dt><var>std</var> and <var>dst</var></dt><dd>
    597  1.1  christos 		are 3 or more characters specifying the standard
    598  1.1  christos 		and daylight saving time (DST) zone names.
    599  1.1  christos 		Starting with POSIX.1-2001, <var>std</var>
    600  1.1  christos 		and <var>dst</var> may also be
    601  1.1  christos 		in a quoted form like '<code>&lt;UTC+10&gt;</code>'; this allows
    602  1.1  christos 		"<code>+</code>" and "<code>-</code>" in the names.
    603  1.1  christos       </dd>
    604  1.1  christos       <dt><var>offset</var></dt><dd>
    605  1.1  christos 		is of the form
    606  1.1  christos 		'<code>[&plusmn;]<var>hh</var>:[<var>mm</var>[:<var>ss</var>]]</code>'
    607  1.1  christos 		and specifies the offset west of UT.  '<var>hh</var>'
    608  1.1  christos 		may be a single digit; 0&le;<var>hh</var>&le;24.
    609  1.1  christos 		The default DST offset is one hour ahead of standard time.
    610  1.1  christos       </dd>
    611  1.1  christos       <dt><var>date</var>[<code>/</code><var>time</var>]<code>,</code><var>date</var>[<code>/</code><var>time</var>]</dt><dd>
    612  1.1  christos 		specifies the beginning and end of DST.  If this is absent,
    613  1.1  christos 		the system supplies its own rules for DST, and these can
    614  1.1  christos 		differ from year to year; typically US DST rules are used.
    615  1.1  christos       </dd>
    616  1.1  christos       <dt><var>time</var></dt><dd>
    617  1.1  christos 		takes the form
    618  1.1  christos 		'<var>hh</var><code>:</code>[<var>mm</var>[<code>:</code><var>ss</var>]]'
    619  1.1  christos 		and defaults to 02:00.
    620  1.1  christos 		This is the same format as the offset, except that a
    621  1.1  christos 		leading '<code>+</code>' or '<code>-</code>' is not allowed.
    622  1.1  christos       </dd>
    623  1.1  christos       <dt><var>date</var></dt><dd>
    624  1.1  christos 		takes one of the following forms:
    625  1.1  christos 	<dl>
    626  1.1  christos 	  <dt>J<var>n</var> (1&le;<var>n</var>&le;365)</dt><dd>
    627  1.1  christos 			origin-1 day number not counting February 29
    628  1.1  christos           </dd>
    629  1.1  christos 	  <dt><var>n</var> (0&le;<var>n</var>&le;365)</dt><dd>
    630  1.1  christos 			origin-0 day number counting February 29 if present
    631  1.1  christos           </dd>
    632  1.1  christos 	  <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>
    633  1.1  christos 			for the <var>d</var>th day of
    634  1.1  christos 			week <var>n</var> of month <var>m</var> of the
    635  1.1  christos 			year, where week 1 is the first week in which
    636  1.1  christos 			day <var>d</var> appears, and '<code>5</code>'
    637  1.1  christos 			stands for the last week in which
    638  1.1  christos 			day <var>d</var> appears
    639  1.1  christos 			(which may be either the 4th or 5th week).
    640  1.1  christos 			Typically, this is the only useful form;
    641  1.1  christos 			the <var>n</var>
    642  1.1  christos 			and <code>J</code><var>n</var> forms are
    643  1.1  christos 			rarely used.
    644  1.1  christos 	  </dd>
    645  1.1  christos </dl>
    646  1.1  christos </dd>
    647  1.1  christos </dl>
    648  1.1  christos 	Here is an example POSIX TZ string for New Zealand after 2007.
    649  1.1  christos 	It says that standard time (NZST) is 12 hours ahead of UTC,
    650  1.1  christos 	and that daylight saving time (NZDT) is observed from September's
    651  1.1  christos 	last Sunday at 02:00 until April's first Sunday at 03:00:
    652  1.1  christos 
    653  1.1  christos         <pre><code>TZ='NZST-12NZDT,M9.5.0,M4.1.0/3'</code></pre>
    654  1.1  christos 
    655  1.1  christos 	This POSIX TZ string is hard to remember, and mishandles some
    656  1.1  christos 	timestamps before 2008.  With this package you can use this
    657  1.1  christos 	instead:
    658  1.1  christos 
    659  1.1  christos 	<pre><code>TZ='Pacific/Auckland'</code></pre>
    660  1.1  christos   </li>
    661  1.1  christos   <li>
    662  1.1  christos 	POSIX does not define the exact meaning of TZ values like
    663  1.1  christos 	"<code>EST5EDT</code>".
    664  1.1  christos 	Typically the current US DST rules are used to interpret such values,
    665  1.1  christos 	but this means that the US DST rules are compiled into each program
    666  1.1  christos 	that does time conversion.  This means that when US time conversion
    667  1.1  christos 	rules change (as in the United States in 1987), all programs that
    668  1.1  christos 	do time conversion must be recompiled to ensure proper results.
    669  1.1  christos   </li>
    670  1.1  christos   <li>
    671  1.1  christos 	The TZ environment variable is process-global, which makes it hard
    672  1.1  christos 	to write efficient, thread-safe applications that need access
    673  1.1  christos 	to multiple time zones.
    674  1.1  christos   </li>
    675  1.1  christos   <li>
    676  1.1  christos 	In POSIX, there's no tamper-proof way for a process to learn the
    677  1.1  christos 	system's best idea of local wall clock.  (This is important for
    678  1.1  christos 	applications that an administrator wants used only at certain
    679  1.1  christos 	times &ndash;
    680  1.1  christos 	without regard to whether the user has fiddled the TZ environment
    681  1.1  christos 	variable.  While an administrator can "do everything in UTC" to get
    682  1.1  christos 	around the problem, doing so is inconvenient and precludes handling
    683  1.1  christos 	daylight saving time shifts - as might be required to limit phone
    684  1.1  christos 	calls to off-peak hours.)
    685  1.1  christos   </li>
    686  1.1  christos   <li>
    687  1.1  christos 	POSIX provides no convenient and efficient way to determine the UT
    688  1.1  christos 	offset and time zone abbreviation of arbitrary timestamps,
    689  1.1  christos 	particularly for time zone settings that do not fit into the
    690  1.1  christos 	POSIX model.
    691  1.1  christos   </li>
    692  1.1  christos   <li>
    693  1.1  christos 	POSIX requires that systems ignore leap seconds.
    694  1.1  christos   </li>
    695  1.1  christos   <li>
    696  1.1  christos 	The tz code attempts to support all the <code>time_t</code>
    697  1.1  christos 	implementations allowed by POSIX.  The <code>time_t</code>
    698  1.1  christos 	type represents a nonnegative count of
    699  1.1  christos 	seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds.
    700  1.1  christos 	In practice, <code>time_t</code> is usually a signed 64- or
    701  1.1  christos 	32-bit integer; 32-bit signed <code>time_t</code> values stop
    702  1.1  christos 	working after 2038-01-19 03:14:07 UTC, so
    703  1.1  christos 	new implementations these days typically use a signed 64-bit integer.
    704  1.1  christos 	Unsigned 32-bit integers are used on one or two platforms,
    705  1.1  christos 	and 36-bit and 40-bit integers are also used occasionally.
    706  1.1  christos 	Although earlier POSIX versions allowed <code>time_t</code> to be a
    707  1.1  christos 	floating-point type, this was not supported by any practical
    708  1.1  christos 	systems, and POSIX.1-2013 and the tz code both
    709  1.1  christos 	require <code>time_t</code>
    710  1.1  christos 	to be an integer type.
    711  1.1  christos   </li>
    712  1.1  christos </ul>
    713  1.1  christos <p>
    714  1.1  christos These are the extensions that have been made to the POSIX functions:
    715  1.1  christos </p>
    716  1.1  christos <ul>
    717  1.1  christos   <li>
    718  1.1  christos     <p>
    719  1.1  christos 	The TZ environment variable is used in generating the name of a file
    720  1.1  christos 	from which time zone information is read (or is interpreted a la
    721  1.1  christos 	POSIX); TZ is no longer constrained to be a three-letter time zone
    722  1.1  christos 	name followed by a number of hours and an optional three-letter
    723  1.1  christos 	daylight time zone name.  The daylight saving time rules to be used
    724  1.1  christos 	for a particular time zone are encoded in the time zone file;
    725  1.1  christos 	the format of the file allows U.S., Australian, and other rules to be
    726  1.1  christos 	encoded, and allows for situations where more than two time zone
    727  1.1  christos 	abbreviations are used.
    728  1.1  christos     </p>
    729  1.1  christos     <p>
    730  1.1  christos 	It was recognized that allowing the TZ environment variable to
    731  1.1  christos 	take on values such as '<code>America/New_York</code>' might
    732  1.1  christos 	cause "old" programs
    733  1.1  christos 	(that expect TZ to have a certain form) to operate incorrectly;
    734  1.1  christos 	consideration was given to using some other environment variable
    735  1.1  christos 	(for example, TIMEZONE) to hold the string used to generate the
    736  1.1  christos 	time zone information file name.  In the end, however, it was decided
    737  1.1  christos 	to continue using TZ: it is widely used for time zone purposes;
    738  1.1  christos 	separately maintaining both TZ and TIMEZONE seemed a nuisance;
    739  1.1  christos 	and systems where "new" forms of TZ might cause problems can simply
    740  1.1  christos 	use TZ values such as "<code>EST5EDT</code>" which can be used both by
    741  1.1  christos 	"new" programs (a la POSIX) and "old" programs (as zone names and
    742  1.1  christos 	offsets).
    743  1.1  christos     </p>
    744  1.1  christos </li>
    745  1.1  christos <li>
    746  1.1  christos 	The code supports platforms with a UT offset member
    747  1.1  christos 	in <code>struct tm</code>,
    748  1.1  christos 	e.g., <code>tm_gmtoff</code>.
    749  1.1  christos </li>
    750  1.1  christos <li>
    751  1.1  christos 	The code supports platforms with a time zone abbreviation member in
    752  1.1  christos 	<code>struct tm</code>, e.g., <code>tm_zone</code>.
    753  1.1  christos </li>
    754  1.1  christos <li>
    755  1.1  christos 	Since the TZ environment variable can now be used to control time
    756  1.1  christos 	conversion, the <code>daylight</code>
    757  1.1  christos 	and <code>timezone</code> variables are no longer needed.
    758  1.1  christos 	(These variables are defined and set by <code>tzset</code>;
    759  1.1  christos 	however, their values will not be used
    760  1.1  christos 	by <code>localtime</code>.)
    761  1.1  christos </li>
    762  1.1  christos <li>
    763  1.1  christos 	Functions <code>tzalloc</code>, <code>tzfree</code>,
    764  1.1  christos 	<code>localtime_rz</code>, and <code>mktime_z</code> for
    765  1.1  christos 	more-efficient thread-safe applications that need to use
    766  1.1  christos 	multiple time zones.  The <code>tzalloc</code>
    767  1.1  christos 	and <code>tzfree</code> functions allocate and free objects of
    768  1.1  christos 	type <code>timezone_t</code>, and <code>localtime_rz</code>
    769  1.1  christos 	and <code>mktime_z</code> are like <code>localtime_r</code>
    770  1.1  christos 	and <code>mktime</code> with an extra
    771  1.1  christos 	<code>timezone_t</code> argument.  The functions were inspired
    772  1.1  christos 	by NetBSD.
    773  1.1  christos </li>
    774  1.1  christos <li>
    775  1.1  christos 	A function <code>tzsetwall</code> has been added to arrange
    776  1.1  christos 	for the system's
    777  1.1  christos 	best approximation to local wall clock time to be delivered by
    778  1.1  christos 	subsequent calls to <code>localtime</code>.  Source code for portable
    779  1.1  christos 	applications that "must" run on local wall clock time should call
    780  1.1  christos 	<code>tzsetwall</code>; if such code is moved to "old" systems that don't
    781  1.1  christos 	provide tzsetwall, you won't be able to generate an executable program.
    782  1.1  christos 	(These time zone functions also arrange for local wall clock time to be
    783  1.1  christos 	used if tzset is called &ndash; directly or indirectly &ndash;
    784  1.1  christos 	and there's no TZ
    785  1.1  christos 	environment variable; portable applications should not, however, rely
    786  1.1  christos 	on this behavior since it's not the way SVR2 systems behave.)
    787  1.1  christos </li>
    788  1.1  christos <li>
    789  1.1  christos 	Negative <code>time_t</code> values are supported, on systems
    790  1.1  christos 	where <code>time_t</code> is signed.
    791  1.1  christos </li>
    792  1.1  christos <li>
    793  1.1  christos 	These functions can account for leap seconds, thanks to Bradley White.
    794  1.1  christos </li>
    795  1.1  christos </ul>
    796  1.1  christos <p>
    797  1.1  christos Points of interest to folks with other systems:
    798  1.1  christos </p>
    799  1.1  christos <ul>
    800  1.1  christos   <li>
    801  1.1  christos 	Code compatible with this package is already part of many platforms,
    802  1.1  christos 	including GNU/Linux, Android, the BSDs, Chromium OS, Cygwin, AIX, iOS,
    803  1.1  christos 	BlackBery 10, macOS, Microsoft Windows, OpenVMS, and Solaris.
    804  1.1  christos 	On such hosts, the primary use of this package
    805  1.1  christos 	is to update obsolete time zone rule tables.
    806  1.1  christos 	To do this, you may need to compile the time zone compiler
    807  1.1  christos 	'<code>zic</code>' supplied with this package instead of using
    808  1.1  christos 	the system '<code>zic</code>', since the format
    809  1.1  christos 	of <code>zic</code>'s input is occasionally extended, and a
    810  1.1  christos 	platform may still be shipping an older <code>zic</code>.
    811  1.1  christos   </li>
    812  1.1  christos   <li>
    813  1.1  christos 	The UNIX Version 7 <code>timezone</code> function is not
    814  1.1  christos 	present in this package;
    815  1.1  christos 	it's impossible to reliably map timezone's arguments (a "minutes west
    816  1.1  christos 	of GMT" value and a "daylight saving time in effect" flag) to a
    817  1.1  christos 	time zone abbreviation, and we refuse to guess.
    818  1.1  christos 	Programs that in the past used the timezone function may now examine
    819  1.1  christos 	<code>localtime(&amp;clock)-&gt;tm_zone</code>
    820  1.1  christos 	(if <code>TM_ZONE</code> is defined) or
    821  1.1  christos 	<code>tzname[localtime(&amp;clock)-&gt;tm_isdst]</code>
    822  1.1  christos 	(if <code>HAVE_TZNAME</code> is defined)
    823  1.1  christos 	to learn the correct time zone abbreviation to use.
    824  1.1  christos   </li>
    825  1.1  christos   <li>
    826  1.1  christos 	The 4.2BSD <code>gettimeofday</code> function is not used in
    827  1.1  christos 	this package.
    828  1.1  christos 	This formerly let users obtain the current UTC offset and DST flag,
    829  1.1  christos 	but this functionality was removed in later versions of BSD.
    830  1.1  christos   </li>
    831  1.1  christos   <li>
    832  1.1  christos 	In SVR2, time conversion fails for near-minimum or near-maximum
    833  1.1  christos 	<code>time_t</code> values when doing conversions for places
    834  1.1  christos 	that don't use UT.
    835  1.1  christos 	This package takes care to do these conversions correctly.
    836  1.1  christos 	A comment in the source code tells how to get compatibly wrong
    837  1.1  christos 	results.
    838  1.1  christos   </li>
    839  1.1  christos </ul>
    840  1.1  christos <p>
    841  1.1  christos The functions that are conditionally compiled
    842  1.1  christos if <code>STD_INSPIRED</code> is defined
    843  1.1  christos should, at this point, be looked on primarily as food for thought.  They are
    844  1.1  christos not in any sense "standard compatible" &ndash; some are not, in fact,
    845  1.1  christos specified in <em>any</em> standard.  They do, however, represent responses of
    846  1.1  christos various authors to
    847  1.1  christos standardization proposals.
    848  1.1  christos </p>
    849  1.1  christos 
    850  1.1  christos <p>
    851  1.1  christos Other time conversion proposals, in particular the one developed by folks at
    852  1.1  christos Hewlett Packard, offer a wider selection of functions that provide capabilities
    853  1.1  christos beyond those provided here.  The absence of such functions from this package
    854  1.1  christos is not meant to discourage the development, standardization, or use of such
    855  1.1  christos functions.  Rather, their absence reflects the decision to make this package
    856  1.1  christos contain valid extensions to POSIX, to ensure its broad acceptability.  If
    857  1.1  christos more powerful time conversion functions can be standardized, so much the
    858  1.1  christos better.
    859  1.1  christos </p>
    860  1.1  christos   </section>
    861  1.1  christos 
    862  1.1  christos 
    863  1.1  christos   <section>
    864  1.1  christos     <h2 id="stability">Interface stability</h2>
    865  1.1  christos <p>
    866  1.1  christos The tz code and data supply the following interfaces:
    867  1.1  christos </p>
    868  1.1  christos <ul>
    869  1.1  christos   <li>
    870  1.1  christos    A set of zone names as per "<a href="#naming">Names of time zone
    871  1.1  christos    rules</a>" above.
    872  1.1  christos   </li>
    873  1.1  christos   <li>
    874  1.1  christos    Library functions described in "<a href="#functions">Time and date
    875  1.1  christos    functions</a>" above.
    876  1.1  christos   </li>
    877  1.1  christos   <li>
    878  1.1  christos    The programs <code>tzselect</code>, <code>zdump</code>,
    879  1.1  christos    and <code>zic</code>, documented in their man pages.
    880  1.1  christos   </li>
    881  1.1  christos   <li>
    882  1.1  christos    The format of <code>zic</code> input files, documented in
    883  1.1  christos    the <code>zic</code> man page.
    884  1.1  christos   </li>
    885  1.1  christos   <li>
    886  1.1  christos    The format of <code>zic</code> output files, documented in
    887  1.1  christos    the <code>tzfile</code> man page.
    888  1.1  christos   </li>
    889  1.1  christos   <li>
    890  1.1  christos    The format of zone table files, documented in <code>zone1970.tab</code>.
    891  1.1  christos   </li>
    892  1.1  christos   <li>
    893  1.1  christos    The format of the country code file, documented in <code>iso3166.tab</code>.
    894  1.1  christos   </li>
    895  1.1  christos   <li>
    896  1.1  christos    The version number of the code and data, as the first line of
    897  1.1  christos    the text file '<code>version</code>' in each release.
    898  1.1  christos   </li>
    899  1.1  christos </ul>
    900  1.1  christos <p>
    901  1.1  christos Interface changes in a release attempt to preserve compatibility with
    902  1.1  christos recent releases.  For example, tz data files typically do not rely on
    903  1.1  christos recently-added <code>zic</code> features, so that users can run
    904  1.1  christos older <code>zic</code> versions to process newer data
    905  1.1  christos files.  <a href="tz-link.htm">Sources for time zone and daylight
    906  1.1  christos saving time data</a> describes how
    907  1.1  christos releases are tagged and distributed.
    908  1.1  christos </p>
    909  1.1  christos 
    910  1.1  christos <p>
    911  1.1  christos Interfaces not listed above are less stable.  For example, users
    912  1.1  christos should not rely on particular UT offsets or abbreviations for
    913  1.1  christos timestamps, as data entries are often based on guesswork and these
    914  1.1  christos guesses may be corrected or improved.
    915  1.1  christos </p>
    916  1.1  christos   </section>
    917  1.1  christos 
    918  1.1  christos 
    919  1.1  christos   <section>
    920  1.1  christos     <h2 id="calendar">Calendrical issues</h2>
    921  1.1  christos <p>
    922  1.1  christos Calendrical issues are a bit out of scope for a time zone database,
    923  1.1  christos but they indicate the sort of problems that we would run into if we
    924  1.1  christos extended the time zone database further into the past.  An excellent
    925  1.1  christos resource in this area is Nachum Dershowitz and Edward M. Reingold,
    926  1.1  christos <cite><a href="https://www.cs.tau.ac.il/~nachum/calendar-book/third-edition/">Calendrical
    927  1.1  christos Calculations: Third Edition</a></cite>, Cambridge University Press (2008).
    928  1.1  christos Other information and sources are given in the file '<samp>calendars</samp>'
    929  1.1  christos in the tz distribution.  They sometimes disagree.
    930  1.1  christos </p>
    931  1.1  christos   </section>
    932  1.1  christos 
    933  1.1  christos 
    934  1.1  christos   <section>
    935  1.1  christos     <h2 id="planets">Time and time zones on other planets</h2>
    936  1.1  christos <p>
    937  1.1  christos Some people's work schedules use Mars time.  Jet Propulsion Laboratory
    938  1.1  christos (JPL) coordinators have kept Mars time on and off at least since 1997
    939  1.1  christos for the Mars Pathfinder mission.  Some of their family members have
    940  1.1  christos also adapted to Mars time.  Dozens of special Mars watches were built
    941  1.1  christos for JPL workers who kept Mars time during the Mars Exploration
    942  1.1  christos Rovers mission (2004).  These timepieces look like normal Seikos and
    943  1.1  christos Citizens but use Mars seconds rather than terrestrial seconds.
    944  1.1  christos </p>
    945  1.1  christos 
    946  1.1  christos <p>
    947  1.1  christos A Mars solar day is called a "sol" and has a mean period equal to
    948  1.1  christos about 24 hours 39 minutes 35.244 seconds in terrestrial time.  It is
    949  1.1  christos divided into a conventional 24-hour clock, so each Mars second equals
    950  1.1  christos about 1.02749125 terrestrial seconds.
    951  1.1  christos </p>
    952  1.1  christos 
    953  1.1  christos <p>
    954  1.1  christos The prime meridian of Mars goes through the center of the crater
    955  1.1  christos Airy-0, named in honor of the British astronomer who built the
    956  1.1  christos Greenwich telescope that defines Earth's prime meridian.  Mean solar
    957  1.1  christos time on the Mars prime meridian is called Mars Coordinated Time (MTC).
    958  1.1  christos </p>
    959  1.1  christos 
    960  1.1  christos <p>
    961  1.1  christos Each landed mission on Mars has adopted a different reference for
    962  1.1  christos solar time keeping, so there is no real standard for Mars time zones.
    963  1.1  christos For example, the Mars Exploration Rover project (2004) defined two
    964  1.1  christos time zones "Local Solar Time A" and "Local Solar Time B" for its two
    965  1.1  christos missions, each zone designed so that its time equals local true solar
    966  1.1  christos time at approximately the middle of the nominal mission.  Such a "time
    967  1.1  christos zone" is not particularly suited for any application other than the
    968  1.1  christos mission itself.
    969  1.1  christos </p>
    970  1.1  christos 
    971  1.1  christos <p>
    972  1.1  christos Many calendars have been proposed for Mars, but none have achieved
    973  1.1  christos wide acceptance.  Astronomers often use Mars Sol Date (MSD) which is a
    974  1.1  christos sequential count of Mars solar days elapsed since about 1873-12-29
    975  1.1  christos 12:00 GMT.
    976  1.1  christos </p>
    977  1.1  christos 
    978  1.1  christos <p>
    979  1.1  christos In our solar system, Mars is the planet with time and calendar most
    980  1.1  christos like Earth's.  On other planets, Sun-based time and calendars would
    981  1.1  christos work quite differently.  For example, although Mercury's sidereal
    982  1.1  christos rotation period is 58.646 Earth days, Mercury revolves around the Sun
    983  1.1  christos so rapidly that an observer on Mercury's equator would see a sunrise
    984  1.1  christos only every 175.97 Earth days, i.e., a Mercury year is 0.5 of a Mercury
    985  1.1  christos day.  Venus is more complicated, partly because its rotation is
    986  1.1  christos slightly retrograde: its year is 1.92 of its days.  Gas giants like
    987  1.1  christos Jupiter are trickier still, as their polar and equatorial regions
    988  1.1  christos rotate at different rates, so that the length of a day depends on
    989  1.1  christos latitude.  This effect is most pronounced on Neptune, where the day is
    990  1.1  christos about 12 hours at the poles and 18 hours at the equator.
    991  1.1  christos </p>
    992  1.1  christos 
    993  1.1  christos <p>
    994  1.1  christos Although the tz database does not support time on other planets, it is
    995  1.1  christos documented here in the hopes that support will be added eventually.
    996  1.1  christos </p>
    997  1.1  christos 
    998  1.1  christos <p>
    999  1.1  christos Sources:
   1000  1.1  christos </p>
   1001  1.1  christos <ul>
   1002  1.1  christos   <li>
   1003  1.1  christos Michael Allison and Robert Schmunk,
   1004  1.1  christos "<a href="https://www.giss.nasa.gov/tools/mars24/help/notes.html">Technical
   1005  1.1  christos Notes on Mars Solar Time as Adopted by the Mars24 Sunclock</a>"
   1006  1.1  christos (2012-08-08).
   1007  1.1  christos   </li>
   1008  1.1  christos   <li>
   1009  1.1  christos Jia-Rui Chong,
   1010  1.1  christos "<a href="http://articles.latimes.com/2004/jan/14/science/sci-marstime14">Workdays
   1011  1.1  christos Fit for a Martian</a>", Los Angeles Times
   1012  1.1  christos (2004-01-14), pp A1, A20-A21.
   1013  1.1  christos   </li>
   1014  1.1  christos   <li>
   1015  1.1  christos Tom Chmielewski,
   1016  1.1  christos "<a href="https://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/">Jet
   1017  1.1  christos Lag Is Worse on Mars</a>", The Atlantic (2015-02-26)
   1018  1.1  christos   </li>
   1019  1.1  christos   <li>
   1020  1.1  christos Matt Williams,
   1021  1.1  christos "<a href="https://www.universetoday.com/37481/days-of-the-planets/">How
   1022  1.1  christos long is a day on the other planets of the solar system?</a>"
   1023  1.1  christos (2017-04-27).
   1024  1.1  christos   </li>
   1025  1.1  christos </ul>
   1026  1.1  christos   </section>
   1027  1.1  christos 
   1028  1.1  christos   <footer>
   1029  1.1  christos     <hr>
   1030  1.1  christos This file is in the public domain, so clarified as of 2009-05-17 by
   1031  1.1  christos Arthur David Olson.
   1032  1.1  christos   </footer>
   1033  1.1  christos </body>
   1034  1.1  christos </html>
   1035