Theory revision 1.21
11.18SchristosTheory and pragmatics of the tz code and data
21.18Schristos
31.2Sperry
41.2Sperry----- Outline -----
51.2Sperry
61.10Schristos	Scope of the tz database
71.18Schristos	Names of time zone rules
81.2Sperry	Time zone abbreviations
91.18Schristos	Accuracy of the tz database
101.18Schristos	Time and date functions
111.4Skleink	Calendrical issues
121.8Skleink	Time and time zones on Mars
131.2Sperry
141.2Sperry
151.18Schristos----- Scope of the tz database -----
161.18Schristos
171.18SchristosThe tz database attempts to record the history and predicted future of
181.18Schristosall computer-based clocks that track civil time.  To represent this
191.18Schristosdata, the world is partitioned into regions whose clocks all agree
201.18Schristosabout time stamps that occur after the somewhat-arbitrary cutoff point
211.18Schristosof the POSIX Epoch (1970-01-01 00:00:00 UTC).  For each such region,
221.18Schristosthe database records all known clock transitions, and labels the region
231.18Schristoswith a notable location.  Although 1970 is a somewhat-arbitrary
241.18Schristoscutoff, there are significant challenges to moving the cutoff earlier
251.18Schristoseven by a decade or two, due to the wide variety of local practices
261.18Schristosbefore computer timekeeping became prevalent.
271.18Schristos
281.18SchristosClock transitions before 1970 are recorded for each such location,
291.18Schristosbecause most systems support time stamps before 1970 and could
301.18Schristosmisbehave if data entries were omitted for pre-1970 transitions.
311.18SchristosHowever, the database is not designed for and does not suffice for
321.18Schristosapplications requiring accurate handling of all past times everywhere,
331.18Schristosas it would take far too much effort and guesswork to record all
341.18Schristosdetails of pre-1970 civil timekeeping.
351.18Schristos
361.18SchristosAs described below, reference source code for using the tz database is
371.18Schristosalso available.  The tz code is upwards compatible with POSIX, an
381.18Schristosinternational standard for UNIX-like systems.  As of this writing, the
391.18Schristoscurrent edition of POSIX is:
401.2Sperry
411.14Schristos  The Open Group Base Specifications Issue 7
421.14Schristos  IEEE Std 1003.1, 2013 Edition
431.14Schristos  <http://pubs.opengroup.org/onlinepubs/9699919799/>
441.2Sperry
451.2Sperry
461.1Sjtc
471.18Schristos----- Names of time zone rules -----
481.2Sperry
491.18SchristosEach of the database's time zone rules has a unique name.
501.18SchristosInexperienced users are not expected to select these names unaided.
511.18SchristosDistributors should provide documentation and/or a simple selection
521.18Schristosinterface that explains the names; for one example, see the 'tzselect'
531.18Schristosprogram in the tz code.  The Unicode Common Locale Data Repository
541.18Schristos<http://cldr.unicode.org/> contains data that may be useful for other
551.18Schristosselection interfaces.
561.2Sperry
571.18SchristosThe time zone rule naming conventions attempt to strike a balance
581.18Schristosamong the following goals:
591.6Skleink
601.18Schristos * Uniquely identify every region where clocks have agreed since 1970.
611.18Schristos   This is essential for the intended use: static clocks keeping local
621.18Schristos   civil time.
631.18Schristos
641.18Schristos * Indicate to experts where that region is.
651.18Schristos
661.18Schristos * Be robust in the presence of political changes.  For example, names
671.18Schristos   of countries are ordinarily not used, to avoid incompatibilities
681.18Schristos   when countries change their name (e.g. Zaire->Congo) or when
691.18Schristos   locations change countries (e.g. Hong Kong from UK colony to
701.18Schristos   China).
711.2Sperry
721.18Schristos * Be portable to a wide variety of implementations.
731.9Smlelstv
741.18Schristos * Use a consistent naming conventions over the entire world.
751.9Smlelstv
761.18SchristosNames normally have the form AREA/LOCATION, where AREA is the name
771.18Schristosof a continent or ocean, and LOCATION is the name of a specific
781.18Schristoslocation within that region.  North and South America share the same
791.18Schristosarea, 'America'.  Typical names are 'Africa/Cairo', 'America/New_York',
801.18Schristosand 'Pacific/Honolulu'.
811.9Smlelstv
821.18SchristosHere are the general rules used for choosing location names,
831.18Schristosin decreasing order of importance:
841.9Smlelstv
851.18Schristos	Use only valid POSIX file name components (i.e., the parts of
861.18Schristos		names other than '/').  Do not use the file name
871.18Schristos		components '.' and '..'.  Within a file name component,
881.18Schristos		use only ASCII letters, '.', '-' and '_'.  Do not use
891.18Schristos		digits, as that might create an ambiguity with POSIX
901.18Schristos		TZ strings.  A file name component must not exceed 14
911.18Schristos		characters or start with '-'.  E.g., prefer 'Brunei'
921.18Schristos		to 'Bandar_Seri_Begawan'.  Exceptions: see the discussion
931.18Schristos		of legacy names below.
941.18Schristos	A name must not be empty, or contain '//', or start or end with '/'.
951.18Schristos	Do not use names that differ only in case.  Although the reference
961.18Schristos		implementation is case-sensitive, some other implementations
971.18Schristos		are not, and they would mishandle names differing only in case.
981.18Schristos	If one name A is an initial prefix of another name AB (ignoring case),
991.18Schristos		then B must not start with '/', as a regular file cannot have
1001.18Schristos		the same name as a directory in POSIX.  For example,
1011.18Schristos		'America/New_York' precludes 'America/New_York/Bronx'.
1021.18Schristos	Uninhabited regions like the North Pole and Bouvet Island
1031.18Schristos		do not need locations, since local time is not defined there.
1041.18Schristos	There should typically be at least one name for each ISO 3166-1
1051.18Schristos		officially assigned two-letter code for an inhabited country
1061.18Schristos		or territory.
1071.18Schristos	If all the clocks in a region have agreed since 1970,
1081.18Schristos		don't bother to include more than one location
1091.18Schristos		even if subregions' clocks disagreed before 1970.
1101.18Schristos		Otherwise these tables would become annoyingly large.
1111.18Schristos	If a name is ambiguous, use a less ambiguous alternative;
1121.18Schristos		e.g. many cities are named San José and Georgetown, so
1131.18Schristos		prefer 'Costa_Rica' to 'San_Jose' and 'Guyana' to 'Georgetown'.
1141.18Schristos	Keep locations compact.  Use cities or small islands, not countries
1151.18Schristos		or regions, so that any future time zone changes do not split
1161.18Schristos		locations into different time zones.  E.g. prefer 'Paris'
1171.18Schristos		to 'France', since France has had multiple time zones.
1181.18Schristos	Use mainstream English spelling, e.g. prefer 'Rome' to 'Roma', and
1191.18Schristos		prefer 'Athens' to the Greek 'Αθήνα' or the Romanized 'Athína'.
1201.18Schristos		The POSIX file name restrictions encourage this rule.
1211.18Schristos	Use the most populous among locations in a zone,
1221.18Schristos		e.g. prefer 'Shanghai' to 'Beijing'.  Among locations with
1231.18Schristos		similar populations, pick the best-known location,
1241.18Schristos		e.g. prefer 'Rome' to 'Milan'.
1251.18Schristos	Use the singular form, e.g. prefer 'Canary' to 'Canaries'.
1261.18Schristos	Omit common suffixes like '_Islands' and '_City', unless that
1271.18Schristos		would lead to ambiguity.  E.g. prefer 'Cayman' to
1281.18Schristos		'Cayman_Islands' and 'Guatemala' to 'Guatemala_City',
1291.18Schristos		but prefer 'Mexico_City' to 'Mexico' because the country
1301.18Schristos		of Mexico has several time zones.
1311.18Schristos	Use '_' to represent a space.
1321.18Schristos	Omit '.' from abbreviations in names, e.g. prefer 'St_Helena'
1331.18Schristos		to 'St._Helena'.
1341.18Schristos	Do not change established names if they only marginally
1351.18Schristos		violate the above rules.  For example, don't change
1361.18Schristos		the existing name 'Rome' to 'Milan' merely because
1371.18Schristos		Milan's population has grown to be somewhat greater
1381.18Schristos		than Rome's.
1391.18Schristos	If a name is changed, put its old spelling in the 'backward' file.
1401.18Schristos		This means old spellings will continue to work.
1411.1Sjtc
1421.18SchristosThe file 'zone1970.tab' lists geographical locations used to name time
1431.18Schristoszone rules.  It is intended to be an exhaustive list of names for
1441.18Schristosgeographic regions as described above; this is a subset of the names
1451.18Schristosin the data.  Although a 'zone1970.tab' location's longitude
1461.18Schristoscorresponds to its LMT offset with one hour for every 15 degrees east
1471.18Schristoslongitude, this relationship is not exact.
1481.1Sjtc
1491.18SchristosOlder versions of this package used a different naming scheme,
1501.18Schristosand these older names are still supported.
1511.18SchristosSee the file 'backward' for most of these older names
1521.18Schristos(e.g., 'US/Eastern' instead of 'America/New_York').
1531.18SchristosThe other old-fashioned names still supported are
1541.18Schristos'WET', 'CET', 'MET', and 'EET' (see the file 'europe').
1551.1Sjtc
1561.18SchristosOlder versions of this package defined legacy names that are
1571.18Schristosincompatible with the first rule of location names, but which are
1581.18Schristosstill supported.  These legacy names are mostly defined in the file
1591.18Schristos'etcetera'.  Also, the file 'backward' defines the legacy names
1601.18Schristos'GMT0', 'GMT-0', 'GMT+0' and 'Canada/East-Saskatchewan', and the file
1611.18Schristos'northamerica' defines the legacy names 'EST5EDT', 'CST6CDT',
1621.18Schristos'MST7MDT', and 'PST8PDT'.
1631.14Schristos
1641.18SchristosExcluding 'backward' should not affect the other data.  If
1651.18Schristos'backward' is excluded, excluding 'etcetera' should not affect the
1661.18Schristosremaining data.
1671.1Sjtc
1681.1Sjtc
1691.18Schristos----- Time zone abbreviations -----
1701.1Sjtc
1711.18SchristosWhen this package is installed, it generates time zone abbreviations
1721.18Schristoslike 'EST' to be compatible with human tradition and POSIX.
1731.18SchristosHere are the general rules used for choosing time zone abbreviations,
1741.18Schristosin decreasing order of importance:
1751.1Sjtc
1761.19Schristos	Use three or more characters that are ASCII alphanumerics or '+' or '-'.
1771.18Schristos		Previous editions of this database also used characters like
1781.18Schristos		' ' and '?', but these characters have a special meaning to
1791.18Schristos		the shell and cause commands like
1801.18Schristos			set `date`
1811.18Schristos		to have unexpected effects.
1821.18Schristos		Previous editions of this rule required upper-case letters,
1831.18Schristos		but the Congressman who introduced Chamorro Standard Time
1841.19Schristos		preferred "ChST", so lower-case letters are now allowed.
1851.19Schristos		Also, POSIX from 2001 on relaxed the rule to allow '-', '+',
1861.19Schristos		and alphanumeric characters from the portable character set
1871.19Schristos		in the current locale.  In practice ASCII alphanumerics and
1881.19Schristos		'+' and '-' are safe in all locales.
1891.1Sjtc
1901.19Schristos		In other words, in the C locale the POSIX extended regular
1911.19Schristos		expression [-+[:alnum:]]{3,} should match the abbreviation.
1921.19Schristos		This guarantees that all abbreviations could have been
1931.19Schristos		specified by a POSIX TZ string.
1941.1Sjtc
1951.18Schristos	Use abbreviations that are in common use among English-speakers,
1961.18Schristos		e.g. 'EST' for Eastern Standard Time in North America.
1971.18Schristos		We assume that applications translate them to other languages
1981.18Schristos		as part of the normal localization process; for example,
1991.18Schristos		a French application might translate 'EST' to 'HNE'.
2001.1Sjtc
2011.18Schristos	For zones whose times are taken from a city's longitude, use the
2021.18Schristos		traditional xMT notation, e.g. 'PMT' for Paris Mean Time.
2031.18Schristos		The only name like this in current use is 'GMT'.
2041.14Schristos
2051.18Schristos	Use 'LMT' for local mean time of locations before the introduction
2061.18Schristos		of standard time; see "Scope of the tz database".
2071.1Sjtc
2081.18Schristos	If there is no common English abbreviation, use numeric offsets like
2091.18Schristos		-05 and +0830 that are generated by zic's %z notation.
2101.2Sperry
2111.18Schristos    [The remaining guidelines predate the introduction of %z.
2121.18Schristos    They are problematic as they mean tz data entries invent
2131.18Schristos    notation rather than record it.  These guidelines are now
2141.18Schristos    deprecated and the plan is to gradually move to %z for
2151.18Schristos    inhabited locations and to "-00" for uninhabited locations.]
2161.2Sperry
2171.18Schristos	If there is no common English abbreviation, abbreviate the English
2181.18Schristos		translation of the usual phrase used by native speakers.
2191.18Schristos		If this is not available or is a phrase mentioning the country
2201.18Schristos		(e.g. "Cape Verde Time"), then:
2211.2Sperry
2221.18Schristos		When a country is identified with a single or principal zone,
2231.18Schristos			append 'T' to the country's ISO	code, e.g. 'CVT' for
2241.18Schristos			Cape Verde Time.  For summer time append 'ST';
2251.18Schristos			for double summer time append 'DST'; etc.
2261.18Schristos		Otherwise, take the first three letters of an English place
2271.18Schristos			name identifying each zone and append 'T', 'ST', etc.
2281.18Schristos			as before; e.g. 'VLAST' for VLAdivostok Summer Time.
2291.1Sjtc
2301.20Schristos	Use UT (with time zone abbreviation '-00') for locations while
2311.20Schristos		uninhabited.  The leading '-' is a flag that the time
2321.20Schristos		zone is in some sense undefined; this notation is
2331.20Schristos		derived from Internet RFC 3339.
2341.2Sperry
2351.18SchristosApplication writers should note that these abbreviations are ambiguous
2361.18Schristosin practice: e.g. 'CST' has a different meaning in China than
2371.18Schristosit does in the United States.  In new applications, it's often better
2381.18Schristosto use numeric UT offsets like '-0600' instead of time zone
2391.18Schristosabbreviations like 'CST'; this avoids the ambiguity.
2401.10Schristos
2411.14Schristos
2421.14Schristos----- Accuracy of the tz database -----
2431.14Schristos
2441.14SchristosThe tz database is not authoritative, and it surely has errors.
2451.16SchristosCorrections are welcome and encouraged; see the file CONTRIBUTING.
2461.16SchristosUsers requiring authoritative data should consult national standards
2471.16Schristosbodies and the references cited in the database's comments.
2481.10Schristos
2491.14SchristosErrors in the tz database arise from many sources:
2501.14Schristos
2511.14Schristos * The tz database predicts future time stamps, and current predictions
2521.14Schristos   will be incorrect after future governments change the rules.
2531.14Schristos   For example, if today someone schedules a meeting for 13:00 next
2541.14Schristos   October 1, Casablanca time, and tomorrow Morocco changes its
2551.14Schristos   daylight saving rules, software can mess up after the rule change
2561.14Schristos   if it blithely relies on conversions made before the change.
2571.14Schristos
2581.16Schristos * The pre-1970 entries in this database cover only a tiny sliver of how
2591.14Schristos   clocks actually behaved; the vast majority of the necessary
2601.14Schristos   information was lost or never recorded.  Thousands more zones would
2611.14Schristos   be needed if the tz database's scope were extended to cover even
2621.14Schristos   just the known or guessed history of standard time; for example,
2631.14Schristos   the current single entry for France would need to split into dozens
2641.19Schristos   of entries, perhaps hundreds.  And in most of the world even this
2651.19Schristos   approach would be misleading due to widespread disagreement or
2661.19Schristos   indifference about what times should be observed.  In her 2015 book
2671.19Schristos   "The Global Transformation of Time, 1870-1950", Vanessa Ogle writes
2681.19Schristos   "Outside of Europe and North America there was no system of time
2691.19Schristos   zones at all, often not even a stable landscape of mean times,
2701.19Schristos   prior to the middle decades of the twentieth century".  See:
2711.19Schristos   Timothy Shenk, Booked: A Global History of Time. Dissent 2015-12-17
2721.19Schristos   https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle
2731.14Schristos
2741.16Schristos * Most of the pre-1970 data entries come from unreliable sources, often
2751.14Schristos   astrology books that lack citations and whose compilers evidently
2761.14Schristos   invented entries when the true facts were unknown, without
2771.14Schristos   reporting which entries were known and which were invented.
2781.14Schristos   These books often contradict each other or give implausible entries,
2791.16Schristos   and on the rare occasions when they are checked they are
2801.14Schristos   typically found to be incorrect.
2811.14Schristos
2821.14Schristos * For the UK the tz database relies on years of first-class work done by
2831.14Schristos   Joseph Myers and others; see <http://www.polyomino.org.uk/british-time/>.
2841.14Schristos   Other countries are not done nearly as well.
2851.14Schristos
2861.14Schristos * Sometimes, different people in the same city would maintain clocks
2871.14Schristos   that differed significantly.  Railway time was used by railroad
2881.14Schristos   companies (which did not always agree with each other),
2891.14Schristos   church-clock time was used for birth certificates, etc.
2901.14Schristos   Often this was merely common practice, but sometimes it was set by law.
2911.14Schristos   For example, from 1891 to 1911 the UT offset in France was legally
2921.14Schristos   0:09:21 outside train stations and 0:04:21 inside.
2931.14Schristos
2941.14Schristos * Although a named location in the tz database stands for the
2951.14Schristos   containing region, its pre-1970 data entries are often accurate for
2961.14Schristos   only a small subset of that region.  For example, Europe/London
2971.14Schristos   stands for the United Kingdom, but its pre-1847 times are valid
2981.14Schristos   only for locations that have London's exact meridian, and its 1847
2991.14Schristos   transition to GMT is known to be valid only for the L&NW and the
3001.14Schristos   Caledonian railways.
3011.14Schristos
3021.16Schristos * The tz database does not record the earliest time for which a zone's
3031.16Schristos   data entries are thereafter valid for every location in the region.
3041.14Schristos   For example, Europe/London is valid for all locations in its
3051.14Schristos   region after GMT was made the standard time, but the date of
3061.14Schristos   standardization (1880-08-02) is not in the tz database, other than
3071.14Schristos   in commentary.  For many zones the earliest time of validity is
3081.14Schristos   unknown.
3091.14Schristos
3101.14Schristos * The tz database does not record a region's boundaries, and in many
3111.14Schristos   cases the boundaries are not known.  For example, the zone
3121.14Schristos   America/Kentucky/Louisville represents a region around the city of
3131.14Schristos   Louisville, the boundaries of which are unclear.
3141.14Schristos
3151.14Schristos * Changes that are modeled as instantaneous transitions in the tz
3161.14Schristos   database were often spread out over hours, days, or even decades.
3171.14Schristos
3181.14Schristos * Even if the time is specified by law, locations sometimes
3191.14Schristos   deliberately flout the law.
3201.14Schristos
3211.14Schristos * Early timekeeping practices, even assuming perfect clocks, were
3221.14Schristos   often not specified to the accuracy that the tz database requires.
3231.14Schristos
3241.14Schristos * Sometimes historical timekeeping was specified more precisely
3251.14Schristos   than what the tz database can handle.  For example, from 1909 to
3261.21Schristos   1937 Netherlands clocks were legally UT +00:19:32.13, but the tz
3271.14Schristos   database cannot represent the fractional second.
3281.14Schristos
3291.14Schristos * Even when all the timestamp transitions recorded by the tz database
3301.14Schristos   are correct, the tz rules that generate them may not faithfully
3311.14Schristos   reflect the historical rules.  For example, from 1922 until World
3321.14Schristos   War II the UK moved clocks forward the day following the third
3331.14Schristos   Saturday in April unless that was Easter, in which case it moved
3341.14Schristos   clocks forward the previous Sunday.  Because the tz database has no
3351.14Schristos   way to specify Easter, these exceptional years are entered as
3361.14Schristos   separate tz Rule lines, even though the legal rules did not change.
3371.14Schristos
3381.16Schristos * The tz database models pre-standard time using the proleptic Gregorian
3391.14Schristos   calendar and local mean time (LMT), but many people used other
3401.14Schristos   calendars and other timescales.  For example, the Roman Empire used
3411.14Schristos   the Julian calendar, and had 12 varying-length daytime hours with a
3421.14Schristos   non-hour-based system at night.
3431.14Schristos
3441.16Schristos * Early clocks were less reliable, and data entries do not represent
3451.16Schristos   this unreliability.
3461.14Schristos
3471.14Schristos * As for leap seconds, civil time was not based on atomic time before
3481.14Schristos   1972, and we don't know the history of earth's rotation accurately
3491.14Schristos   enough to map SI seconds to historical solar time to more than
3501.14Schristos   about one-hour accuracy.  See: Morrison LV, Stephenson FR.
3511.14Schristos   Historical values of the Earth's clock error Delta T and the
3521.14Schristos   calculation of eclipses. J Hist Astron. 2004;35:327-36
3531.14Schristos   <http://adsabs.harvard.edu/full/2004JHA....35..327M>;
3541.14Schristos   Historical values of the Earth's clock error. J Hist Astron. 2005;36:339
3551.14Schristos   <http://adsabs.harvard.edu/full/2005JHA....36..339M>.
3561.14Schristos
3571.14Schristos * The relationship between POSIX time (that is, UTC but ignoring leap
3581.14Schristos   seconds) and UTC is not agreed upon after 1972.  Although the POSIX
3591.14Schristos   clock officially stops during an inserted leap second, at least one
3601.14Schristos   proposed standard has it jumping back a second instead; and in
3611.14Schristos   practice POSIX clocks more typically either progress glacially during
3621.14Schristos   a leap second, or are slightly slowed while near a leap second.
3631.14Schristos
3641.14Schristos * The tz database does not represent how uncertain its information is.
3651.16Schristos   Ideally it would contain information about when data entries are
3661.14Schristos   incomplete or dicey.  Partial temporal knowledge is a field of
3671.14Schristos   active research, though, and it's not clear how to apply it here.
3681.14Schristos
3691.14SchristosIn short, many, perhaps most, of the tz database's pre-1970 and future
3701.14Schristostime stamps are either wrong or misleading.  Any attempt to pass the
3711.14Schristostz database off as the definition of time should be unacceptable to
3721.14Schristosanybody who cares about the facts.  In particular, the tz database's
3731.14SchristosLMT offsets should not be considered meaningful, and should not prompt
3741.14Schristoscreation of zones merely because two locations differ in LMT or
3751.14Schristostransitioned to standard time at different dates.
3761.14Schristos
3771.10Schristos
3781.18Schristos----- Time and date functions -----
3791.18Schristos
3801.18SchristosThe tz code contains time and date functions that are upwards
3811.18Schristoscompatible with those of POSIX.
3821.18Schristos
3831.18SchristosPOSIX has the following properties and limitations.
3841.18Schristos
3851.18Schristos*	In POSIX, time display in a process is controlled by the
3861.18Schristos	environment variable TZ.  Unfortunately, the POSIX TZ string takes
3871.18Schristos	a form that is hard to describe and is error-prone in practice.
3881.18Schristos	Also, POSIX TZ strings can't deal with other (for example, Israeli)
3891.18Schristos	daylight saving time rules, or situations where more than two
3901.18Schristos	time zone abbreviations are used in an area.
3911.18Schristos
3921.18Schristos	The POSIX TZ string takes the following form:
3931.18Schristos
3941.18Schristos		stdoffset[dst[offset][,date[/time],date[/time]]]
3951.18Schristos
3961.18Schristos	where:
3971.18Schristos
3981.18Schristos	std and dst
3991.18Schristos		are 3 or more characters specifying the standard
4001.18Schristos		and daylight saving time (DST) zone names.
4011.18Schristos		Starting with POSIX.1-2001, std and dst may also be
4021.18Schristos		in a quoted form like "<UTC+10>"; this allows
4031.18Schristos		"+" and "-" in the names.
4041.18Schristos	offset
4051.18Schristos		is of the form '[+-]hh:[mm[:ss]]' and specifies the
4061.18Schristos		offset west of UT.  'hh' may be a single digit; 0<=hh<=24.
4071.18Schristos		The default DST offset is one hour ahead of standard time.
4081.18Schristos	date[/time],date[/time]
4091.18Schristos		specifies the beginning and end of DST.  If this is absent,
4101.18Schristos		the system supplies its own rules for DST, and these can
4111.18Schristos		differ from year to year; typically US DST rules are used.
4121.18Schristos	time
4131.18Schristos		takes the form 'hh:[mm[:ss]]' and defaults to 02:00.
4141.18Schristos		This is the same format as the offset, except that a
4151.18Schristos		leading '+' or '-' is not allowed.
4161.18Schristos	date
4171.18Schristos		takes one of the following forms:
4181.18Schristos		Jn (1<=n<=365)
4191.18Schristos			origin-1 day number not counting February 29
4201.18Schristos		n (0<=n<=365)
4211.18Schristos			origin-0 day number counting February 29 if present
4221.18Schristos		Mm.n.d (0[Sunday]<=d<=6[Saturday], 1<=n<=5, 1<=m<=12)
4231.18Schristos			for the dth day of week n of month m of the year,
4241.18Schristos			where week 1 is the first week in which day d appears,
4251.18Schristos			and '5' stands for the last week in which day d appears
4261.18Schristos			(which may be either the 4th or 5th week).
4271.18Schristos			Typically, this is the only useful form;
4281.18Schristos			the n and Jn forms are rarely used.
4291.18Schristos
4301.18Schristos	Here is an example POSIX TZ string, for US Pacific time using rules
4311.18Schristos	appropriate from 1987 through 2006:
4321.2Sperry
4331.18Schristos		TZ='PST8PDT,M4.1.0/02:00,M10.5.0/02:00'
4341.6Skleink
4351.18Schristos	This POSIX TZ string is hard to remember, and mishandles time stamps
4361.18Schristos	before 1987 and after 2006.  With this package you can use this
4371.18Schristos	instead:
4381.6Skleink
4391.18Schristos		TZ='America/Los_Angeles'
4401.6Skleink
4411.18Schristos*	POSIX does not define the exact meaning of TZ values like "EST5EDT".
4421.18Schristos	Typically the current US DST rules are used to interpret such values,
4431.18Schristos	but this means that the US DST rules are compiled into each program
4441.18Schristos	that does time conversion.  This means that when US time conversion
4451.18Schristos	rules change (as in the United States in 1987), all programs that
4461.18Schristos	do time conversion must be recompiled to ensure proper results.
4471.6Skleink
4481.18Schristos*	In POSIX, there's no tamper-proof way for a process to learn the
4491.18Schristos	system's best idea of local wall clock.  (This is important for
4501.18Schristos	applications that an administrator wants used only at certain times -
4511.18Schristos	without regard to whether the user has fiddled the "TZ" environment
4521.18Schristos	variable.  While an administrator can "do everything in UTC" to get
4531.18Schristos	around the problem, doing so is inconvenient and precludes handling
4541.18Schristos	daylight saving time shifts - as might be required to limit phone
4551.18Schristos	calls to off-peak hours.)
4561.2Sperry
4571.18Schristos*	POSIX requires that systems ignore leap seconds.
4581.2Sperry
4591.18Schristos*	The tz code attempts to support all the time_t implementations
4601.18Schristos	allowed by POSIX.  The time_t type represents a nonnegative count of
4611.18Schristos	seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds.
4621.18Schristos	In practice, time_t is usually a signed 64- or 32-bit integer; 32-bit
4631.18Schristos	signed time_t values stop working after 2038-01-19 03:14:07 UTC, so
4641.18Schristos	new implementations these days typically use a signed 64-bit integer.
4651.18Schristos	Unsigned 32-bit integers are used on one or two platforms,
4661.18Schristos	and 36-bit and 40-bit integers are also used occasionally.
4671.18Schristos	Although earlier POSIX versions allowed time_t to be a
4681.18Schristos	floating-point type, this was not supported by any practical
4691.18Schristos	systems, and POSIX.1-2013 and the tz code both require time_t
4701.18Schristos	to be an integer type.
4711.2Sperry
4721.18SchristosThese are the extensions that have been made to the POSIX functions:
4731.2Sperry
4741.18Schristos*	The "TZ" environment variable is used in generating the name of a file
4751.18Schristos	from which time zone information is read (or is interpreted a la
4761.18Schristos	POSIX); "TZ" is no longer constrained to be a three-letter time zone
4771.18Schristos	name followed by a number of hours and an optional three-letter
4781.18Schristos	daylight time zone name.  The daylight saving time rules to be used
4791.18Schristos	for a particular time zone are encoded in the time zone file;
4801.18Schristos	the format of the file allows U.S., Australian, and other rules to be
4811.18Schristos	encoded, and allows for situations where more than two time zone
4821.18Schristos	abbreviations are used.
4831.2Sperry
4841.18Schristos	It was recognized that allowing the "TZ" environment variable to
4851.18Schristos	take on values such as "America/New_York" might cause "old" programs
4861.18Schristos	(that expect "TZ" to have a certain form) to operate incorrectly;
4871.18Schristos	consideration was given to using some other environment variable
4881.18Schristos	(for example, "TIMEZONE") to hold the string used to generate the
4891.18Schristos	time zone information file name.  In the end, however, it was decided
4901.18Schristos	to continue using "TZ": it is widely used for time zone purposes;
4911.18Schristos	separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance;
4921.18Schristos	and systems where "new" forms of "TZ" might cause problems can simply
4931.18Schristos	use TZ values such as "EST5EDT" which can be used both by
4941.18Schristos	"new" programs (a la POSIX) and "old" programs (as zone names and
4951.18Schristos	offsets).
4961.2Sperry
4971.18Schristos*	To handle places where more than two time zone abbreviations are used,
4981.18Schristos	the functions "localtime" and "gmtime" set tzname[tmp->tm_isdst]
4991.18Schristos	(where "tmp" is the value the function returns) to the time zone
5001.18Schristos	abbreviation to be used.  This differs from POSIX, where the elements
5011.18Schristos	of tzname are only changed as a result of calls to tzset.
5021.15Schristos
5031.18Schristos*	Since the "TZ" environment variable can now be used to control time
5041.18Schristos	conversion, the "daylight" and "timezone" variables are no longer
5051.18Schristos	needed.  (These variables are defined and set by "tzset"; however, their
5061.18Schristos	values will not be used by "localtime.")
5071.15Schristos
5081.18Schristos*	The "localtime" function has been set up to deliver correct results
5091.18Schristos	for near-minimum or near-maximum time_t values.  (A comment in the
5101.18Schristos	source code tells how to get compatibly wrong results).
5111.2Sperry
5121.18Schristos*	A function "tzsetwall" has been added to arrange for the system's
5131.18Schristos	best approximation to local wall clock time to be delivered by
5141.18Schristos	subsequent calls to "localtime."  Source code for portable
5151.18Schristos	applications that "must" run on local wall clock time should call
5161.18Schristos	"tzsetwall();" if such code is moved to "old" systems that don't
5171.18Schristos	provide tzsetwall, you won't be able to generate an executable program.
5181.18Schristos	(These time zone functions also arrange for local wall clock time to be
5191.18Schristos	used if tzset is called - directly or indirectly - and there's no "TZ"
5201.18Schristos	environment variable; portable applications should not, however, rely
5211.18Schristos	on this behavior since it's not the way SVR2 systems behave.)
5221.2Sperry
5231.18Schristos*	Negative time_t values are supported, on systems where time_t is signed.
5241.2Sperry
5251.18Schristos*	These functions can account for leap seconds, thanks to Bradley White.
5261.6Skleink
5271.18SchristosPoints of interest to folks with other systems:
5281.6Skleink
5291.18Schristos*	This package is already part of many POSIX-compliant hosts,
5301.18Schristos	including BSD, HP, Linux, Network Appliance, SCO, SGI, and Sun.
5311.18Schristos	On such hosts, the primary use of this package
5321.18Schristos	is to update obsolete time zone rule tables.
5331.18Schristos	To do this, you may need to compile the time zone compiler
5341.18Schristos	'zic' supplied with this package instead of using the system 'zic',
5351.18Schristos	since the format of zic's input changed slightly in late 1994,
5361.18Schristos	and many vendors still do not support the new input format.
5371.6Skleink
5381.18Schristos*	The UNIX Version 7 "timezone" function is not present in this package;
5391.18Schristos	it's impossible to reliably map timezone's arguments (a "minutes west
5401.18Schristos	of GMT" value and a "daylight saving time in effect" flag) to a
5411.18Schristos	time zone abbreviation, and we refuse to guess.
5421.18Schristos	Programs that in the past used the timezone function may now examine
5431.18Schristos	tzname[localtime(&clock)->tm_isdst] to learn the correct time
5441.18Schristos	zone abbreviation to use.  Alternatively, use
5451.18Schristos	localtime(&clock)->tm_zone if this has been enabled.
5461.6Skleink
5471.18Schristos*	The 4.2BSD gettimeofday function is not used in this package.
5481.18Schristos	This formerly let users obtain the current UTC offset and DST flag,
5491.18Schristos	but this functionality was removed in later versions of BSD.
5501.2Sperry
5511.18Schristos*	In SVR2, time conversion fails for near-minimum or near-maximum
5521.18Schristos	time_t values when doing conversions for places that don't use UT.
5531.18Schristos	This package takes care to do these conversions correctly.
5541.2Sperry
5551.18SchristosThe functions that are conditionally compiled if STD_INSPIRED is defined
5561.18Schristosshould, at this point, be looked on primarily as food for thought.  They are
5571.18Schristosnot in any sense "standard compatible" - some are not, in fact, specified in
5581.18Schristos*any* standard.  They do, however, represent responses of various authors to
5591.18Schristosstandardization proposals.
5601.14Schristos
5611.18SchristosOther time conversion proposals, in particular the one developed by folks at
5621.18SchristosHewlett Packard, offer a wider selection of functions that provide capabilities
5631.18Schristosbeyond those provided here.  The absence of such functions from this package
5641.18Schristosis not meant to discourage the development, standardization, or use of such
5651.18Schristosfunctions.  Rather, their absence reflects the decision to make this package
5661.18Schristoscontain valid extensions to POSIX, to ensure its broad acceptability.  If
5671.18Schristosmore powerful time conversion functions can be standardized, so much the
5681.18Schristosbetter.
5691.4Skleink
5701.4Skleink
5711.4Skleink----- Calendrical issues -----
5721.4Skleink
5731.4SkleinkCalendrical issues are a bit out of scope for a time zone database,
5741.4Skleinkbut they indicate the sort of problems that we would run into if we
5751.4Skleinkextended the time zone database further into the past.  An excellent
5761.10Schristosresource in this area is Nachum Dershowitz and Edward M. Reingold,
5771.15SchristosCalendrical Calculations: Third Edition, Cambridge University Press (2008)
5781.15Schristos<http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/>.
5791.15SchristosOther information and sources are given below.  They sometimes disagree.
5801.4Skleink
5811.4Skleink
5821.4SkleinkFrance
5831.4Skleink
5841.4SkleinkGregorian calendar adopted 1582-12-20.
5851.4SkleinkFrench Revolutionary calendar used 1793-11-24 through 1805-12-31,
5861.4Skleinkand (in Paris only) 1871-05-06 through 1871-05-23.
5871.4Skleink
5881.4Skleink
5891.4SkleinkRussia
5901.4Skleink
5911.9SmlelstvFrom Chris Carrier (1996-12-02):
5921.14SchristosOn 1929-10-01 the Soviet Union instituted an "Eternal Calendar"
5931.4Skleinkwith 30-day months plus 5 holidays, with a 5-day week.
5941.4SkleinkOn 1931-12-01 it changed to a 6-day week; in 1934 it reverted to the
5951.4SkleinkGregorian calendar while retaining the 6-day week; on 1940-06-27 it
5961.4Skleinkreverted to the 7-day week.  With the 6-day week the usual days
5971.4Skleinkoff were the 6th, 12th, 18th, 24th and 30th of the month.
5981.4Skleink(Source: Evitiar Zerubavel, _The Seven Day Circle_)
5991.4Skleink
6001.4Skleink
6011.4SkleinkMark Brader reported a similar story in "The Book of Calendars", edited
6021.4Skleinkby Frank Parise (1982, Facts on File, ISBN 0-8719-6467-8), page 377.  But:
6031.4Skleink
6041.4SkleinkFrom: Petteri Sulonen (via Usenet)
6051.4SkleinkDate: 14 Jan 1999 00:00:00 GMT
6061.9Smlelstv...
6071.4Skleink
6081.15SchristosIf your source is correct, how come documents between 1929 and 1940 were
6091.4Skleinkstill dated using the conventional, Gregorian calendar?
6101.4Skleink
6111.4SkleinkI can post a scan of a document dated December 1, 1934, signed by
6121.4SkleinkYenukidze, the secretary, on behalf of Kalinin, the President of the
6131.4SkleinkExecutive Committee of the Supreme Soviet, if you like.
6141.4Skleink
6151.4Skleink
6161.4Skleink
6171.4SkleinkSweden (and Finland)
6181.4Skleink
6191.9SmlelstvFrom: Mark Brader
6201.15SchristosSubject: Re: Gregorian reform - a part of locale?
6211.15Schristos<news:1996Jul6.012937.29190@sq.com>
6221.4SkleinkDate: 1996-07-06
6231.4Skleink
6241.4SkleinkIn 1700, Denmark made the transition from Julian to Gregorian.  Sweden
6251.4Skleinkdecided to *start* a transition in 1700 as well, but rather than have one of
6261.4Skleinkthose unsightly calendar gaps :-), they simply decreed that the next leap
6271.15Schristosyear after 1696 would be in 1744 - putting the whole country on a calendar
6281.4Skleinkdifferent from both Julian and Gregorian for a period of 40 years.
6291.4Skleink
6301.4SkleinkHowever, in 1704 something went wrong and the plan was not carried through;
6311.4Skleinkthey did, after all, have a leap year that year.  And one in 1708.  In 1712
6321.4Skleinkthey gave it up and went back to Julian, putting 30 days in February that
6331.4Skleinkyear!...
6341.4Skleink
6351.4SkleinkThen in 1753, Sweden made the transition to Gregorian in the usual manner,
6361.4Skleinkgetting there only 13 years behind the original schedule.
6371.4Skleink
6381.4Skleink(A previous posting of this story was challenged, and Swedish readers
6391.15Schristosproduced the following references to support it: "Tideräkning och historia"
6401.15Schristosby Natanael Beckman (1924) and "Tid, en bok om tideräkning och
6411.15Schristoskalenderväsen" by Lars-Olof Lodén (1968).
6421.4Skleink
6431.4Skleink
6441.4SkleinkGrotefend's data
6451.4Skleink
6461.9SmlelstvFrom: "Michael Palmer" [with one obvious typo fixed]
6471.4SkleinkSubject: Re: Gregorian Calendar (was Re: Another FHC related question
6481.4SkleinkNewsgroups: soc.genealogy.german
6491.4SkleinkDate: Tue, 9 Feb 1999 02:32:48 -800
6501.9Smlelstv...
6511.4Skleink
6521.6SkleinkThe following is a(n incomplete) listing, arranged chronologically, of
6531.6SkleinkEuropean states, with the date they converted from the Julian to the
6541.4SkleinkGregorian calendar:
6551.4Skleink
6561.4Skleink04/15 Oct 1582 - Italy (with exceptions), Spain, Portugal, Poland (Roman
6571.4Skleink                 Catholics and Danzig only)
6581.4Skleink09/20 Dec 1582 - France, Lorraine
6591.4Skleink
6601.4Skleink21 Dec 1582/
6611.4Skleink   01 Jan 1583 - Holland, Brabant, Flanders, Hennegau
6621.15Schristos10/21 Feb 1583 - bishopric of Liege (Lüttich)
6631.4Skleink13/24 Feb 1583 - bishopric of Augsburg
6641.4Skleink04/15 Oct 1583 - electorate of Trier
6651.4Skleink05/16 Oct 1583 - Bavaria, bishoprics of Freising, Eichstedt, Regensburg,
6661.4Skleink                 Salzburg, Brixen
6671.15Schristos13/24 Oct 1583 - Austrian Oberelsaß and Breisgau
6681.4Skleink20/31 Oct 1583 - bishopric of Basel
6691.15Schristos02/13 Nov 1583 - duchy of Jülich-Berg
6701.15Schristos02/13 Nov 1583 - electorate and city of Köln
6711.15Schristos04/15 Nov 1583 - bishopric of Würzburg
6721.4Skleink11/22 Nov 1583 - electorate of Mainz
6731.4Skleink16/27 Nov 1583 - bishopric of Strassburg and the margraviate of Baden
6741.15Schristos17/28 Nov 1583 - bishopric of Münster and duchy of Cleve
6751.4Skleink14/25 Dec 1583 - Steiermark
6761.4Skleink
6771.4Skleink06/17 Jan 1584 - Austria and Bohemia
6781.15Schristos11/22 Jan 1584 - Lucerne, Uri, Schwyz, Zug, Freiburg, Solothurn
6791.4Skleink12/23 Jan 1584 - Silesia and the Lausitz
6801.4Skleink22 Jan/
6811.4Skleink   02 Feb 1584 - Hungary (legally on 21 Oct 1587)
6821.4Skleink      Jun 1584 - Unterwalden
6831.4Skleink01/12 Jul 1584 - duchy of Westfalen
6841.4Skleink
6851.4Skleink16/27 Jun 1585 - bishopric of Paderborn
6861.4Skleink
6871.4Skleink14/25 Dec 1590 - Transylvania
6881.4Skleink
6891.4Skleink22 Aug/
6901.4Skleink   02 Sep 1612 - duchy of Prussia
6911.4Skleink
6921.4Skleink13/24 Dec 1614 - Pfalz-Neuburg
6931.4Skleink
6941.4Skleink          1617 - duchy of Kurland (reverted to the Julian calendar in
6951.4Skleink                 1796)
6961.4Skleink
6971.15Schristos          1624 - bishopric of Osnabrück
6981.4Skleink
6991.4Skleink          1630 - bishopric of Minden
7001.4Skleink
7011.4Skleink15/26 Mar 1631 - bishopric of Hildesheim
7021.4Skleink
7031.4Skleink          1655 - Kanton Wallis
7041.4Skleink
7051.4Skleink05/16 Feb 1682 - city of Strassburg
7061.4Skleink
7071.4Skleink18 Feb/
7081.4Skleink   01 Mar 1700 - Protestant Germany (including Swedish possessions in
7091.4Skleink                 Germany), Denmark, Norway
7101.4Skleink30 Jun/
7111.4Skleink   12 Jul 1700 - Gelderland, Zutphen
7121.4Skleink10 Nov/
7131.4Skleink   12 Dec 1700 - Utrecht, Overijssel
7141.4Skleink
7151.4Skleink31 Dec 1700/
7161.15Schristos   12 Jan 1701 - Friesland, Groningen, Zürich, Bern, Basel, Geneva,
7171.4Skleink                 Turgau, and Schaffhausen
7181.4Skleink
7191.4Skleink          1724 - Glarus, Appenzell, and the city of St. Gallen
7201.4Skleink
7211.4Skleink01 Jan 1750    - Pisa and Florence
7221.4Skleink
7231.4Skleink02/14 Sep 1752 - Great Britain
7241.4Skleink
7251.4Skleink17 Feb/
7261.4Skleink   01 Mar 1753 - Sweden
7271.4Skleink
7281.15Schristos1760-1812      - Graubünden
7291.4Skleink
7301.6SkleinkThe Russian empire (including Finland and the Baltic states) did not
7311.4Skleinkconvert to the Gregorian calendar until the Soviet revolution of 1917.
7321.4Skleink
7331.16SchristosSource: H. Grotefend, _Taschenbuch der Zeitrechnung des deutschen
7341.6SkleinkMittelalters und der Neuzeit_, herausgegeben von Dr. O. Grotefend
7351.16Schristos(Hannover: Hahnsche Buchhandlung, 1941), pp. 26-28.
7361.8Skleink
7371.8Skleink
7381.8Skleink----- Time and time zones on Mars -----
7391.8Skleink
7401.17SchristosSome people's work schedules use Mars time.  Jet Propulsion Laboratory
7411.17Schristos(JPL) coordinators have kept Mars time on and off at least since 1997
7421.17Schristosfor the Mars Pathfinder mission.  Some of their family members have
7431.17Schristosalso adapted to Mars time.  Dozens of special Mars watches were built
7441.17Schristosfor JPL workers who kept Mars time during the Mars Exploration
7451.8SkleinkRovers mission (2004).  These timepieces look like normal Seikos and
7461.8SkleinkCitizens but use Mars seconds rather than terrestrial seconds.
7471.8Skleink
7481.8SkleinkA Mars solar day is called a "sol" and has a mean period equal to
7491.8Skleinkabout 24 hours 39 minutes 35.244 seconds in terrestrial time.  It is
7501.8Skleinkdivided into a conventional 24-hour clock, so each Mars second equals
7511.8Skleinkabout 1.02749125 terrestrial seconds.
7521.8Skleink
7531.8SkleinkThe prime meridian of Mars goes through the center of the crater
7541.8SkleinkAiry-0, named in honor of the British astronomer who built the
7551.8SkleinkGreenwich telescope that defines Earth's prime meridian.  Mean solar
7561.8Skleinktime on the Mars prime meridian is called Mars Coordinated Time (MTC).
7571.8Skleink
7581.8SkleinkEach landed mission on Mars has adopted a different reference for
7591.8Skleinksolar time keeping, so there is no real standard for Mars time zones.
7601.8SkleinkFor example, the Mars Exploration Rover project (2004) defined two
7611.8Skleinktime zones "Local Solar Time A" and "Local Solar Time B" for its two
7621.8Skleinkmissions, each zone designed so that its time equals local true solar
7631.8Skleinktime at approximately the middle of the nominal mission.  Such a "time
7641.8Skleinkzone" is not particularly suited for any application other than the
7651.8Skleinkmission itself.
7661.8Skleink
7671.8SkleinkMany calendars have been proposed for Mars, but none have achieved
7681.8Skleinkwide acceptance.  Astronomers often use Mars Sol Date (MSD) which is a
7691.8Skleinksequential count of Mars solar days elapsed since about 1873-12-29
7701.8Skleink12:00 GMT.
7711.8Skleink
7721.8SkleinkThe tz database does not currently support Mars time, but it is
7731.8Skleinkdocumented here in the hopes that support will be added eventually.
7741.8Skleink
7751.8SkleinkSources:
7761.8Skleink
7771.8SkleinkMichael Allison and Robert Schmunk,
7781.8Skleink"Technical Notes on Mars Solar Time as Adopted by the Mars24 Sunclock"
7791.13Schristos<http://www.giss.nasa.gov/tools/mars24/help/notes.html> (2012-08-08).
7801.8Skleink
7811.8SkleinkJia-Rui Chong, "Workdays Fit for a Martian", Los Angeles Times
7821.13Schristos<http://articles.latimes.com/2004/jan/14/science/sci-marstime14>
7831.8Skleink(2004-01-14), pp A1, A20-A21.
7841.15Schristos
7851.17SchristosTom Chmielewski, "Jet Lag Is Worse on Mars", The Atlantic (2015-02-26)
7861.17Schristos<http://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/>
7871.15Schristos
7881.15Schristos-----
7891.18Schristos
7901.18SchristosThis file is in the public domain, so clarified as of 2009-05-17 by
7911.18SchristosArthur David Olson.
7921.18Schristos
7931.18Schristos-----
7941.15SchristosLocal Variables:
7951.15Schristoscoding: utf-8
7961.15SchristosEnd:
797