1309576SglebiusTheory and pragmatics of the tz code and data 2309576Sglebius 3309576Sglebius 4309576Sglebius----- Outline ----- 5309576Sglebius 6309576Sglebius Scope of the tz database 7309576Sglebius Names of time zone rules 8309576Sglebius Time zone abbreviations 9309576Sglebius Accuracy of the tz database 10309576Sglebius Time and date functions 11309576Sglebius Calendrical issues 12309576Sglebius Time and time zones on Mars 13309576Sglebius 14309576Sglebius 15309576Sglebius----- Scope of the tz database ----- 16309576Sglebius 17309576SglebiusThe tz database attempts to record the history and predicted future of 18309576Sglebiusall computer-based clocks that track civil time. To represent this 19309576Sglebiusdata, the world is partitioned into regions whose clocks all agree 20309576Sglebiusabout time stamps that occur after the somewhat-arbitrary cutoff point 21309576Sglebiusof the POSIX Epoch (1970-01-01 00:00:00 UTC). For each such region, 22309576Sglebiusthe database records all known clock transitions, and labels the region 23309576Sglebiuswith a notable location. Although 1970 is a somewhat-arbitrary 24309576Sglebiuscutoff, there are significant challenges to moving the cutoff earlier 25309576Sglebiuseven by a decade or two, due to the wide variety of local practices 26309576Sglebiusbefore computer timekeeping became prevalent. 27309576Sglebius 28309576SglebiusClock transitions before 1970 are recorded for each such location, 29309576Sglebiusbecause most systems support time stamps before 1970 and could 30309576Sglebiusmisbehave if data entries were omitted for pre-1970 transitions. 31309576SglebiusHowever, the database is not designed for and does not suffice for 32309576Sglebiusapplications requiring accurate handling of all past times everywhere, 33309576Sglebiusas it would take far too much effort and guesswork to record all 34309576Sglebiusdetails of pre-1970 civil timekeeping. 35309576Sglebius 36309576SglebiusAs described below, reference source code for using the tz database is 37309576Sglebiusalso available. The tz code is upwards compatible with POSIX, an 38309576Sglebiusinternational standard for UNIX-like systems. As of this writing, the 39309576Sglebiuscurrent edition of POSIX is: 40309576Sglebius 41309576Sglebius The Open Group Base Specifications Issue 7 42309576Sglebius IEEE Std 1003.1, 2013 Edition 43309576Sglebius <http://pubs.opengroup.org/onlinepubs/9699919799/> 44309576Sglebius 45309576Sglebius 46309576Sglebius 47309576Sglebius----- Names of time zone rules ----- 48309576Sglebius 49309576SglebiusEach of the database's time zone rules has a unique name. 50309576SglebiusInexperienced users are not expected to select these names unaided. 51309576SglebiusDistributors should provide documentation and/or a simple selection 52309576Sglebiusinterface that explains the names; for one example, see the 'tzselect' 53309576Sglebiusprogram in the tz code. The Unicode Common Locale Data Repository 54309576Sglebius<http://cldr.unicode.org/> contains data that may be useful for other 55309576Sglebiusselection interfaces. 56309576Sglebius 57309576SglebiusThe time zone rule naming conventions attempt to strike a balance 58309576Sglebiusamong the following goals: 59309576Sglebius 60309576Sglebius * Uniquely identify every region where clocks have agreed since 1970. 61309576Sglebius This is essential for the intended use: static clocks keeping local 62309576Sglebius civil time. 63309576Sglebius 64309576Sglebius * Indicate to experts where that region is. 65309576Sglebius 66309576Sglebius * Be robust in the presence of political changes. For example, names 67309576Sglebius of countries are ordinarily not used, to avoid incompatibilities 68309576Sglebius when countries change their name (e.g. Zaire->Congo) or when 69309576Sglebius locations change countries (e.g. Hong Kong from UK colony to 70309576Sglebius China). 71309576Sglebius 72309576Sglebius * Be portable to a wide variety of implementations. 73309576Sglebius 74309576Sglebius * Use a consistent naming conventions over the entire world. 75309576Sglebius 76309576SglebiusNames normally have the form AREA/LOCATION, where AREA is the name 77309576Sglebiusof a continent or ocean, and LOCATION is the name of a specific 78309576Sglebiuslocation within that region. North and South America share the same 79309576Sglebiusarea, 'America'. Typical names are 'Africa/Cairo', 'America/New_York', 80309576Sglebiusand 'Pacific/Honolulu'. 81309576Sglebius 82309576SglebiusHere are the general rules used for choosing location names, 83309576Sglebiusin decreasing order of importance: 84309576Sglebius 85309576Sglebius Use only valid POSIX file name components (i.e., the parts of 86309576Sglebius names other than '/'). Do not use the file name 87309576Sglebius components '.' and '..'. Within a file name component, 88309576Sglebius use only ASCII letters, '.', '-' and '_'. Do not use 89309576Sglebius digits, as that might create an ambiguity with POSIX 90309576Sglebius TZ strings. A file name component must not exceed 14 91309576Sglebius characters or start with '-'. E.g., prefer 'Brunei' 92309576Sglebius to 'Bandar_Seri_Begawan'. Exceptions: see the discussion 93309576Sglebius of legacy names below. 94309576Sglebius A name must not be empty, or contain '//', or start or end with '/'. 95309576Sglebius Do not use names that differ only in case. Although the reference 96309576Sglebius implementation is case-sensitive, some other implementations 97309576Sglebius are not, and they would mishandle names differing only in case. 98309576Sglebius If one name A is an initial prefix of another name AB (ignoring case), 99309576Sglebius then B must not start with '/', as a regular file cannot have 100309576Sglebius the same name as a directory in POSIX. For example, 101309576Sglebius 'America/New_York' precludes 'America/New_York/Bronx'. 102309576Sglebius Uninhabited regions like the North Pole and Bouvet Island 103309576Sglebius do not need locations, since local time is not defined there. 104309576Sglebius There should typically be at least one name for each ISO 3166-1 105309576Sglebius officially assigned two-letter code for an inhabited country 106309576Sglebius or territory. 107309576Sglebius If all the clocks in a region have agreed since 1970, 108309576Sglebius don't bother to include more than one location 109309576Sglebius even if subregions' clocks disagreed before 1970. 110309576Sglebius Otherwise these tables would become annoyingly large. 111309576Sglebius If a name is ambiguous, use a less ambiguous alternative; 112309576Sglebius e.g. many cities are named San Jos�� and Georgetown, so 113309576Sglebius prefer 'Costa_Rica' to 'San_Jose' and 'Guyana' to 'Georgetown'. 114309576Sglebius Keep locations compact. Use cities or small islands, not countries 115309576Sglebius or regions, so that any future time zone changes do not split 116309576Sglebius locations into different time zones. E.g. prefer 'Paris' 117309576Sglebius to 'France', since France has had multiple time zones. 118309576Sglebius Use mainstream English spelling, e.g. prefer 'Rome' to 'Roma', and 119309576Sglebius prefer 'Athens' to the Greek '����������' or the Romanized 'Ath��na'. 120309576Sglebius The POSIX file name restrictions encourage this rule. 121309576Sglebius Use the most populous among locations in a zone, 122309576Sglebius e.g. prefer 'Shanghai' to 'Beijing'. Among locations with 123309576Sglebius similar populations, pick the best-known location, 124309576Sglebius e.g. prefer 'Rome' to 'Milan'. 125309576Sglebius Use the singular form, e.g. prefer 'Canary' to 'Canaries'. 126309576Sglebius Omit common suffixes like '_Islands' and '_City', unless that 127309576Sglebius would lead to ambiguity. E.g. prefer 'Cayman' to 128309576Sglebius 'Cayman_Islands' and 'Guatemala' to 'Guatemala_City', 129309576Sglebius but prefer 'Mexico_City' to 'Mexico' because the country 130309576Sglebius of Mexico has several time zones. 131309576Sglebius Use '_' to represent a space. 132309576Sglebius Omit '.' from abbreviations in names, e.g. prefer 'St_Helena' 133309576Sglebius to 'St._Helena'. 134309576Sglebius Do not change established names if they only marginally 135309576Sglebius violate the above rules. For example, don't change 136309576Sglebius the existing name 'Rome' to 'Milan' merely because 137309576Sglebius Milan's population has grown to be somewhat greater 138309576Sglebius than Rome's. 139309576Sglebius If a name is changed, put its old spelling in the 'backward' file. 140309576Sglebius This means old spellings will continue to work. 141309576Sglebius 142309576SglebiusThe file 'zone1970.tab' lists geographical locations used to name time 143309576Sglebiuszone rules. It is intended to be an exhaustive list of names for 144309576Sglebiusgeographic regions as described above; this is a subset of the names 145309576Sglebiusin the data. Although a 'zone1970.tab' location's longitude 146309576Sglebiuscorresponds to its LMT offset with one hour for every 15 degrees east 147309576Sglebiuslongitude, this relationship is not exact. 148309576Sglebius 149309576SglebiusOlder versions of this package used a different naming scheme, 150309576Sglebiusand these older names are still supported. 151309576SglebiusSee the file 'backward' for most of these older names 152309576Sglebius(e.g., 'US/Eastern' instead of 'America/New_York'). 153309576SglebiusThe other old-fashioned names still supported are 154309576Sglebius'WET', 'CET', 'MET', and 'EET' (see the file 'europe'). 155309576Sglebius 156309576SglebiusOlder versions of this package defined legacy names that are 157309576Sglebiusincompatible with the first rule of location names, but which are 158309576Sglebiusstill supported. These legacy names are mostly defined in the file 159309576Sglebius'etcetera'. Also, the file 'backward' defines the legacy names 160309576Sglebius'GMT0', 'GMT-0', 'GMT+0' and 'Canada/East-Saskatchewan', and the file 161309576Sglebius'northamerica' defines the legacy names 'EST5EDT', 'CST6CDT', 162309576Sglebius'MST7MDT', and 'PST8PDT'. 163309576Sglebius 164309576SglebiusExcluding 'backward' should not affect the other data. If 165309576Sglebius'backward' is excluded, excluding 'etcetera' should not affect the 166309576Sglebiusremaining data. 167309576Sglebius 168309576Sglebius 169309576Sglebius----- Time zone abbreviations ----- 170309576Sglebius 171309576SglebiusWhen this package is installed, it generates time zone abbreviations 172309576Sglebiuslike 'EST' to be compatible with human tradition and POSIX. 173309576SglebiusHere are the general rules used for choosing time zone abbreviations, 174309576Sglebiusin decreasing order of importance: 175309576Sglebius 176309576Sglebius Use three or more characters that are ASCII alphanumerics or '+' or '-'. 177309576Sglebius Previous editions of this database also used characters like 178309576Sglebius ' ' and '?', but these characters have a special meaning to 179309576Sglebius the shell and cause commands like 180309576Sglebius set `date` 181309576Sglebius to have unexpected effects. 182309576Sglebius Previous editions of this rule required upper-case letters, 183309576Sglebius but the Congressman who introduced Chamorro Standard Time 184309576Sglebius preferred "ChST", so lower-case letters are now allowed. 185309576Sglebius Also, POSIX from 2001 on relaxed the rule to allow '-', '+', 186309576Sglebius and alphanumeric characters from the portable character set 187309576Sglebius in the current locale. In practice ASCII alphanumerics and 188309576Sglebius '+' and '-' are safe in all locales. 189309576Sglebius 190309576Sglebius In other words, in the C locale the POSIX extended regular 191309576Sglebius expression [-+[:alnum:]]{3,} should match the abbreviation. 192309576Sglebius This guarantees that all abbreviations could have been 193309576Sglebius specified by a POSIX TZ string. 194309576Sglebius 195309576Sglebius Use abbreviations that are in common use among English-speakers, 196309576Sglebius e.g. 'EST' for Eastern Standard Time in North America. 197309576Sglebius We assume that applications translate them to other languages 198309576Sglebius as part of the normal localization process; for example, 199309576Sglebius a French application might translate 'EST' to 'HNE'. 200309576Sglebius 201309576Sglebius For zones whose times are taken from a city's longitude, use the 202309576Sglebius traditional xMT notation, e.g. 'PMT' for Paris Mean Time. 203309576Sglebius The only name like this in current use is 'GMT'. 204309576Sglebius 205309576Sglebius Use 'LMT' for local mean time of locations before the introduction 206309576Sglebius of standard time; see "Scope of the tz database". 207309576Sglebius 208309576Sglebius If there is no common English abbreviation, use numeric offsets like 209309576Sglebius -05 and +0830 that are generated by zic's %z notation. 210309576Sglebius 211309576Sglebius [The remaining guidelines predate the introduction of %z. 212309576Sglebius They are problematic as they mean tz data entries invent 213309576Sglebius notation rather than record it. These guidelines are now 214309576Sglebius deprecated and the plan is to gradually move to %z for 215309576Sglebius inhabited locations and to "-00" for uninhabited locations.] 216309576Sglebius 217309576Sglebius If there is no common English abbreviation, abbreviate the English 218309576Sglebius translation of the usual phrase used by native speakers. 219309576Sglebius If this is not available or is a phrase mentioning the country 220309576Sglebius (e.g. "Cape Verde Time"), then: 221309576Sglebius 222309576Sglebius When a country is identified with a single or principal zone, 223309576Sglebius append 'T' to the country's ISO code, e.g. 'CVT' for 224309576Sglebius Cape Verde Time. For summer time append 'ST'; 225309576Sglebius for double summer time append 'DST'; etc. 226309576Sglebius Otherwise, take the first three letters of an English place 227309576Sglebius name identifying each zone and append 'T', 'ST', etc. 228309576Sglebius as before; e.g. 'VLAST' for VLAdivostok Summer Time. 229309576Sglebius 230309576Sglebius Use UT (with time zone abbreviation '-00') for locations while 231309576Sglebius uninhabited. The leading '-' is a flag that the time 232309576Sglebius zone is in some sense undefined; this notation is 233309576Sglebius derived from Internet RFC 3339. 234309576Sglebius 235309576SglebiusApplication writers should note that these abbreviations are ambiguous 236309576Sglebiusin practice: e.g. 'CST' has a different meaning in China than 237309576Sglebiusit does in the United States. In new applications, it's often better 238309576Sglebiusto use numeric UT offsets like '-0600' instead of time zone 239309576Sglebiusabbreviations like 'CST'; this avoids the ambiguity. 240309576Sglebius 241309576Sglebius 242309576Sglebius----- Accuracy of the tz database ----- 243309576Sglebius 244309576SglebiusThe tz database is not authoritative, and it surely has errors. 245309576SglebiusCorrections are welcome and encouraged; see the file CONTRIBUTING. 246309576SglebiusUsers requiring authoritative data should consult national standards 247309576Sglebiusbodies and the references cited in the database's comments. 248309576Sglebius 249309576SglebiusErrors in the tz database arise from many sources: 250309576Sglebius 251309576Sglebius * The tz database predicts future time stamps, and current predictions 252309576Sglebius will be incorrect after future governments change the rules. 253309576Sglebius For example, if today someone schedules a meeting for 13:00 next 254309576Sglebius October 1, Casablanca time, and tomorrow Morocco changes its 255309576Sglebius daylight saving rules, software can mess up after the rule change 256309576Sglebius if it blithely relies on conversions made before the change. 257309576Sglebius 258309576Sglebius * The pre-1970 entries in this database cover only a tiny sliver of how 259309576Sglebius clocks actually behaved; the vast majority of the necessary 260309576Sglebius information was lost or never recorded. Thousands more zones would 261309576Sglebius be needed if the tz database's scope were extended to cover even 262309576Sglebius just the known or guessed history of standard time; for example, 263309576Sglebius the current single entry for France would need to split into dozens 264309576Sglebius of entries, perhaps hundreds. And in most of the world even this 265309576Sglebius approach would be misleading due to widespread disagreement or 266309576Sglebius indifference about what times should be observed. In her 2015 book 267309576Sglebius "The Global Transformation of Time, 1870-1950", Vanessa Ogle writes 268309576Sglebius "Outside of Europe and North America there was no system of time 269309576Sglebius zones at all, often not even a stable landscape of mean times, 270309576Sglebius prior to the middle decades of the twentieth century". See: 271309576Sglebius Timothy Shenk, Booked: A Global History of Time. Dissent 2015-12-17 272309576Sglebius https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle 273309576Sglebius 274309576Sglebius * Most of the pre-1970 data entries come from unreliable sources, often 275309576Sglebius astrology books that lack citations and whose compilers evidently 276309576Sglebius invented entries when the true facts were unknown, without 277309576Sglebius reporting which entries were known and which were invented. 278309576Sglebius These books often contradict each other or give implausible entries, 279309576Sglebius and on the rare occasions when they are checked they are 280309576Sglebius typically found to be incorrect. 281309576Sglebius 282309576Sglebius * For the UK the tz database relies on years of first-class work done by 283309576Sglebius Joseph Myers and others; see <http://www.polyomino.org.uk/british-time/>. 284309576Sglebius Other countries are not done nearly as well. 285309576Sglebius 286309576Sglebius * Sometimes, different people in the same city would maintain clocks 287309576Sglebius that differed significantly. Railway time was used by railroad 288309576Sglebius companies (which did not always agree with each other), 289309576Sglebius church-clock time was used for birth certificates, etc. 290309576Sglebius Often this was merely common practice, but sometimes it was set by law. 291309576Sglebius For example, from 1891 to 1911 the UT offset in France was legally 292309576Sglebius 0:09:21 outside train stations and 0:04:21 inside. 293309576Sglebius 294309576Sglebius * Although a named location in the tz database stands for the 295309576Sglebius containing region, its pre-1970 data entries are often accurate for 296309576Sglebius only a small subset of that region. For example, Europe/London 297309576Sglebius stands for the United Kingdom, but its pre-1847 times are valid 298309576Sglebius only for locations that have London's exact meridian, and its 1847 299309576Sglebius transition to GMT is known to be valid only for the L&NW and the 300309576Sglebius Caledonian railways. 301309576Sglebius 302309576Sglebius * The tz database does not record the earliest time for which a zone's 303309576Sglebius data entries are thereafter valid for every location in the region. 304309576Sglebius For example, Europe/London is valid for all locations in its 305309576Sglebius region after GMT was made the standard time, but the date of 306309576Sglebius standardization (1880-08-02) is not in the tz database, other than 307309576Sglebius in commentary. For many zones the earliest time of validity is 308309576Sglebius unknown. 309309576Sglebius 310309576Sglebius * The tz database does not record a region's boundaries, and in many 311309576Sglebius cases the boundaries are not known. For example, the zone 312309576Sglebius America/Kentucky/Louisville represents a region around the city of 313309576Sglebius Louisville, the boundaries of which are unclear. 314309576Sglebius 315309576Sglebius * Changes that are modeled as instantaneous transitions in the tz 316309576Sglebius database were often spread out over hours, days, or even decades. 317309576Sglebius 318309576Sglebius * Even if the time is specified by law, locations sometimes 319309576Sglebius deliberately flout the law. 320309576Sglebius 321309576Sglebius * Early timekeeping practices, even assuming perfect clocks, were 322309576Sglebius often not specified to the accuracy that the tz database requires. 323309576Sglebius 324309576Sglebius * Sometimes historical timekeeping was specified more precisely 325309576Sglebius than what the tz database can handle. For example, from 1909 to 326309576Sglebius 1937 Netherlands clocks were legally UT +00:19:32.13, but the tz 327309576Sglebius database cannot represent the fractional second. 328309576Sglebius 329309576Sglebius * Even when all the timestamp transitions recorded by the tz database 330309576Sglebius are correct, the tz rules that generate them may not faithfully 331309576Sglebius reflect the historical rules. For example, from 1922 until World 332309576Sglebius War II the UK moved clocks forward the day following the third 333309576Sglebius Saturday in April unless that was Easter, in which case it moved 334309576Sglebius clocks forward the previous Sunday. Because the tz database has no 335309576Sglebius way to specify Easter, these exceptional years are entered as 336309576Sglebius separate tz Rule lines, even though the legal rules did not change. 337309576Sglebius 338309576Sglebius * The tz database models pre-standard time using the proleptic Gregorian 339309576Sglebius calendar and local mean time (LMT), but many people used other 340309576Sglebius calendars and other timescales. For example, the Roman Empire used 341309576Sglebius the Julian calendar, and had 12 varying-length daytime hours with a 342309576Sglebius non-hour-based system at night. 343309576Sglebius 344309576Sglebius * Early clocks were less reliable, and data entries do not represent 345309576Sglebius this unreliability. 346309576Sglebius 347309576Sglebius * As for leap seconds, civil time was not based on atomic time before 348309576Sglebius 1972, and we don't know the history of earth's rotation accurately 349309576Sglebius enough to map SI seconds to historical solar time to more than 350309576Sglebius about one-hour accuracy. See: Morrison LV, Stephenson FR. 351309576Sglebius Historical values of the Earth's clock error Delta T and the 352309576Sglebius calculation of eclipses. J Hist Astron. 2004;35:327-36 353309576Sglebius <http://adsabs.harvard.edu/full/2004JHA....35..327M>; 354309576Sglebius Historical values of the Earth's clock error. J Hist Astron. 2005;36:339 355309576Sglebius <http://adsabs.harvard.edu/full/2005JHA....36..339M>. 356309576Sglebius 357309576Sglebius * The relationship between POSIX time (that is, UTC but ignoring leap 358309576Sglebius seconds) and UTC is not agreed upon after 1972. Although the POSIX 359309576Sglebius clock officially stops during an inserted leap second, at least one 360309576Sglebius proposed standard has it jumping back a second instead; and in 361309576Sglebius practice POSIX clocks more typically either progress glacially during 362309576Sglebius a leap second, or are slightly slowed while near a leap second. 363309576Sglebius 364309576Sglebius * The tz database does not represent how uncertain its information is. 365309576Sglebius Ideally it would contain information about when data entries are 366309576Sglebius incomplete or dicey. Partial temporal knowledge is a field of 367309576Sglebius active research, though, and it's not clear how to apply it here. 368309576Sglebius 369309576SglebiusIn short, many, perhaps most, of the tz database's pre-1970 and future 370309576Sglebiustime stamps are either wrong or misleading. Any attempt to pass the 371309576Sglebiustz database off as the definition of time should be unacceptable to 372309576Sglebiusanybody who cares about the facts. In particular, the tz database's 373309576SglebiusLMT offsets should not be considered meaningful, and should not prompt 374309576Sglebiuscreation of zones merely because two locations differ in LMT or 375309576Sglebiustransitioned to standard time at different dates. 376309576Sglebius 377309576Sglebius 378309576Sglebius----- Time and date functions ----- 379309576Sglebius 380309576SglebiusThe tz code contains time and date functions that are upwards 381309576Sglebiuscompatible with those of POSIX. 382309576Sglebius 383309576SglebiusPOSIX has the following properties and limitations. 384309576Sglebius 385309576Sglebius* In POSIX, time display in a process is controlled by the 386309576Sglebius environment variable TZ. Unfortunately, the POSIX TZ string takes 387309576Sglebius a form that is hard to describe and is error-prone in practice. 388309576Sglebius Also, POSIX TZ strings can't deal with other (for example, Israeli) 389309576Sglebius daylight saving time rules, or situations where more than two 390309576Sglebius time zone abbreviations are used in an area. 391309576Sglebius 392309576Sglebius The POSIX TZ string takes the following form: 393309576Sglebius 394309576Sglebius stdoffset[dst[offset][,date[/time],date[/time]]] 395309576Sglebius 396309576Sglebius where: 397309576Sglebius 398309576Sglebius std and dst 399309576Sglebius are 3 or more characters specifying the standard 400309576Sglebius and daylight saving time (DST) zone names. 401309576Sglebius Starting with POSIX.1-2001, std and dst may also be 402309576Sglebius in a quoted form like "<UTC+10>"; this allows 403309576Sglebius "+" and "-" in the names. 404309576Sglebius offset 405309576Sglebius is of the form '[+-]hh:[mm[:ss]]' and specifies the 406309576Sglebius offset west of UT. 'hh' may be a single digit; 0<=hh<=24. 407309576Sglebius The default DST offset is one hour ahead of standard time. 408309576Sglebius date[/time],date[/time] 409309576Sglebius specifies the beginning and end of DST. If this is absent, 410309576Sglebius the system supplies its own rules for DST, and these can 411309576Sglebius differ from year to year; typically US DST rules are used. 412309576Sglebius time 413309576Sglebius takes the form 'hh:[mm[:ss]]' and defaults to 02:00. 414309576Sglebius This is the same format as the offset, except that a 415309576Sglebius leading '+' or '-' is not allowed. 416309576Sglebius date 417309576Sglebius takes one of the following forms: 418309576Sglebius Jn (1<=n<=365) 419309576Sglebius origin-1 day number not counting February 29 420309576Sglebius n (0<=n<=365) 421309576Sglebius origin-0 day number counting February 29 if present 422309576Sglebius Mm.n.d (0[Sunday]<=d<=6[Saturday], 1<=n<=5, 1<=m<=12) 423309576Sglebius for the dth day of week n of month m of the year, 424309576Sglebius where week 1 is the first week in which day d appears, 425309576Sglebius and '5' stands for the last week in which day d appears 426309576Sglebius (which may be either the 4th or 5th week). 427309576Sglebius Typically, this is the only useful form; 428309576Sglebius the n and Jn forms are rarely used. 429309576Sglebius 430309576Sglebius Here is an example POSIX TZ string, for US Pacific time using rules 431309576Sglebius appropriate from 1987 through 2006: 432309576Sglebius 433309576Sglebius TZ='PST8PDT,M4.1.0/02:00,M10.5.0/02:00' 434309576Sglebius 435309576Sglebius This POSIX TZ string is hard to remember, and mishandles time stamps 436309576Sglebius before 1987 and after 2006. With this package you can use this 437309576Sglebius instead: 438309576Sglebius 439309576Sglebius TZ='America/Los_Angeles' 440309576Sglebius 441309576Sglebius* POSIX does not define the exact meaning of TZ values like "EST5EDT". 442309576Sglebius Typically the current US DST rules are used to interpret such values, 443309576Sglebius but this means that the US DST rules are compiled into each program 444309576Sglebius that does time conversion. This means that when US time conversion 445309576Sglebius rules change (as in the United States in 1987), all programs that 446309576Sglebius do time conversion must be recompiled to ensure proper results. 447309576Sglebius 448309576Sglebius* The TZ environment variable is process-global, which makes it hard 449309576Sglebius to write efficient, thread-safe applications that need access 450309576Sglebius to multiple time zones. 451309576Sglebius 452309576Sglebius* In POSIX, there's no tamper-proof way for a process to learn the 453309576Sglebius system's best idea of local wall clock. (This is important for 454309576Sglebius applications that an administrator wants used only at certain times - 455309576Sglebius without regard to whether the user has fiddled the "TZ" environment 456309576Sglebius variable. While an administrator can "do everything in UTC" to get 457309576Sglebius around the problem, doing so is inconvenient and precludes handling 458309576Sglebius daylight saving time shifts - as might be required to limit phone 459309576Sglebius calls to off-peak hours.) 460309576Sglebius 461309576Sglebius* POSIX provides no convenient and efficient way to determine the UT 462309576Sglebius offset and time zone abbreviation of arbitrary time stamps, 463309576Sglebius particularly for time zone settings that do not fit into the 464309576Sglebius POSIX model. 465309576Sglebius 466309576Sglebius* POSIX requires that systems ignore leap seconds. 467309576Sglebius 468309576Sglebius* The tz code attempts to support all the time_t implementations 469309576Sglebius allowed by POSIX. The time_t type represents a nonnegative count of 470309576Sglebius seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds. 471309576Sglebius In practice, time_t is usually a signed 64- or 32-bit integer; 32-bit 472309576Sglebius signed time_t values stop working after 2038-01-19 03:14:07 UTC, so 473309576Sglebius new implementations these days typically use a signed 64-bit integer. 474309576Sglebius Unsigned 32-bit integers are used on one or two platforms, 475309576Sglebius and 36-bit and 40-bit integers are also used occasionally. 476309576Sglebius Although earlier POSIX versions allowed time_t to be a 477309576Sglebius floating-point type, this was not supported by any practical 478309576Sglebius systems, and POSIX.1-2013 and the tz code both require time_t 479309576Sglebius to be an integer type. 480309576Sglebius 481309576SglebiusThese are the extensions that have been made to the POSIX functions: 482309576Sglebius 483309576Sglebius* The "TZ" environment variable is used in generating the name of a file 484309576Sglebius from which time zone information is read (or is interpreted a la 485309576Sglebius POSIX); "TZ" is no longer constrained to be a three-letter time zone 486309576Sglebius name followed by a number of hours and an optional three-letter 487309576Sglebius daylight time zone name. The daylight saving time rules to be used 488309576Sglebius for a particular time zone are encoded in the time zone file; 489309576Sglebius the format of the file allows U.S., Australian, and other rules to be 490309576Sglebius encoded, and allows for situations where more than two time zone 491309576Sglebius abbreviations are used. 492309576Sglebius 493309576Sglebius It was recognized that allowing the "TZ" environment variable to 494309576Sglebius take on values such as "America/New_York" might cause "old" programs 495309576Sglebius (that expect "TZ" to have a certain form) to operate incorrectly; 496309576Sglebius consideration was given to using some other environment variable 497309576Sglebius (for example, "TIMEZONE") to hold the string used to generate the 498309576Sglebius time zone information file name. In the end, however, it was decided 499309576Sglebius to continue using "TZ": it is widely used for time zone purposes; 500309576Sglebius separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance; 501309576Sglebius and systems where "new" forms of "TZ" might cause problems can simply 502309576Sglebius use TZ values such as "EST5EDT" which can be used both by 503309576Sglebius "new" programs (a la POSIX) and "old" programs (as zone names and 504309576Sglebius offsets). 505309576Sglebius 506309576Sglebius* The code supports platforms with a UT offset member in struct tm, 507309576Sglebius e.g., tm_gmtoff. 508309576Sglebius 509309576Sglebius* The code supports platforms with a time zone abbreviation member in 510309576Sglebius struct tm, e.g., tm_zone. 511309576Sglebius 512309576Sglebius* Since the "TZ" environment variable can now be used to control time 513309576Sglebius conversion, the "daylight" and "timezone" variables are no longer 514309576Sglebius needed. (These variables are defined and set by "tzset"; however, their 515309576Sglebius values will not be used by "localtime.") 516309576Sglebius 517309576Sglebius* Functions tzalloc, tzfree, localtime_rz, and mktime_z for 518309576Sglebius more-efficient thread-safe applications that need to use 519309576Sglebius multiple time zones. The tzalloc and tzfree functions 520309576Sglebius allocate and free objects of type timezone_t, and localtime_rz 521309576Sglebius and mktime_z are like localtime_r and mktime with an extra 522309576Sglebius timezone_t argument. The functions were inspired by NetBSD. 523309576Sglebius 524309576Sglebius* A function "tzsetwall" has been added to arrange for the system's 525309576Sglebius best approximation to local wall clock time to be delivered by 526309576Sglebius subsequent calls to "localtime." Source code for portable 527309576Sglebius applications that "must" run on local wall clock time should call 528309576Sglebius "tzsetwall();" if such code is moved to "old" systems that don't 529309576Sglebius provide tzsetwall, you won't be able to generate an executable program. 530309576Sglebius (These time zone functions also arrange for local wall clock time to be 531309576Sglebius used if tzset is called - directly or indirectly - and there's no "TZ" 532309576Sglebius environment variable; portable applications should not, however, rely 533309576Sglebius on this behavior since it's not the way SVR2 systems behave.) 534309576Sglebius 535309576Sglebius* Negative time_t values are supported, on systems where time_t is signed. 536309576Sglebius 537309576Sglebius* These functions can account for leap seconds, thanks to Bradley White. 538309576Sglebius 539309576SglebiusPoints of interest to folks with other systems: 540309576Sglebius 541309576Sglebius* Code compatible with this package is already part of many platforms, 542309576Sglebius including GNU/Linux, Android, the BSDs, Chromium OS, Cygwin, AIX, iOS, 543309576Sglebius BlackBery 10, macOS, Microsoft Windows, OpenVMS, and Solaris. 544309576Sglebius On such hosts, the primary use of this package 545309576Sglebius is to update obsolete time zone rule tables. 546309576Sglebius To do this, you may need to compile the time zone compiler 547309576Sglebius 'zic' supplied with this package instead of using the system 'zic', 548309576Sglebius since the format of zic's input is occasionally extended, 549309576Sglebius and a platform may still be shipping an older zic. 550309576Sglebius 551309576Sglebius* The UNIX Version 7 "timezone" function is not present in this package; 552309576Sglebius it's impossible to reliably map timezone's arguments (a "minutes west 553309576Sglebius of GMT" value and a "daylight saving time in effect" flag) to a 554309576Sglebius time zone abbreviation, and we refuse to guess. 555309576Sglebius Programs that in the past used the timezone function may now examine 556309576Sglebius tzname[localtime(&clock)->tm_isdst] to learn the correct time 557309576Sglebius zone abbreviation to use. Alternatively, use 558309576Sglebius localtime(&clock)->tm_zone if this has been enabled. 559309576Sglebius 560309576Sglebius* The 4.2BSD gettimeofday function is not used in this package. 561309576Sglebius This formerly let users obtain the current UTC offset and DST flag, 562309576Sglebius but this functionality was removed in later versions of BSD. 563309576Sglebius 564309576Sglebius* In SVR2, time conversion fails for near-minimum or near-maximum 565309576Sglebius time_t values when doing conversions for places that don't use UT. 566309576Sglebius This package takes care to do these conversions correctly. 567309576Sglebius A comment in the source code tells how to get compatibly wrong 568309576Sglebius results. 569309576Sglebius 570309576SglebiusThe functions that are conditionally compiled if STD_INSPIRED is defined 571309576Sglebiusshould, at this point, be looked on primarily as food for thought. They are 572309576Sglebiusnot in any sense "standard compatible" - some are not, in fact, specified in 573309576Sglebius*any* standard. They do, however, represent responses of various authors to 574309576Sglebiusstandardization proposals. 575309576Sglebius 576309576SglebiusOther time conversion proposals, in particular the one developed by folks at 577309576SglebiusHewlett Packard, offer a wider selection of functions that provide capabilities 578309576Sglebiusbeyond those provided here. The absence of such functions from this package 579309576Sglebiusis not meant to discourage the development, standardization, or use of such 580309576Sglebiusfunctions. Rather, their absence reflects the decision to make this package 581309576Sglebiuscontain valid extensions to POSIX, to ensure its broad acceptability. If 582309576Sglebiusmore powerful time conversion functions can be standardized, so much the 583309576Sglebiusbetter. 584309576Sglebius 585309576Sglebius 586309576Sglebius----- Interface stability ----- 587309576Sglebius 588309576SglebiusThe tz code and data supply the following interfaces: 589309576Sglebius 590309576Sglebius * A set of zone names as per "Names of time zone rules" above. 591309576Sglebius 592309576Sglebius * Library functions described in "Time and date functions" above. 593309576Sglebius 594309576Sglebius * The programs tzselect, zdump, and zic, documented in their man pages. 595309576Sglebius 596309576Sglebius * The format of zic input files, documented in the zic man page. 597309576Sglebius 598309576Sglebius * The format of zic output files, documented in the tzfile man page. 599309576Sglebius 600309576Sglebius * The format of zone table files, documented in zone1970.tab. 601309576Sglebius 602309576Sglebius * The format of the country code file, documented in iso3166.tab. 603309576Sglebius 604309576SglebiusWhen these interfaces are changed, an effort is made to preserve 605309576Sglebiusbackward compatibility. For example, tz data files typically do not 606309576Sglebiusrely on recently-added zic features, so that users can run older zic 607309576Sglebiusversions to process newer data files. 608309576Sglebius 609309576SglebiusInterfaces not listed above are less stable. For example, users 610309576Sglebiusshould not rely on particular UT offsets or abbreviations for time 611309576Sglebiusstamps, as data entries are often based on guesswork and these guesses 612309576Sglebiusmay be corrected or improved. 613309576Sglebius 614309576Sglebius 615309576Sglebius----- Calendrical issues ----- 616309576Sglebius 617309576SglebiusCalendrical issues are a bit out of scope for a time zone database, 618309576Sglebiusbut they indicate the sort of problems that we would run into if we 619309576Sglebiusextended the time zone database further into the past. An excellent 620309576Sglebiusresource in this area is Nachum Dershowitz and Edward M. Reingold, 621309576SglebiusCalendrical Calculations: Third Edition, Cambridge University Press (2008) 622309576Sglebius<http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/>. 623309576SglebiusOther information and sources are given below. They sometimes disagree. 624309576Sglebius 625309576Sglebius 626309576SglebiusFrance 627309576Sglebius 628309576SglebiusGregorian calendar adopted 1582-12-20. 629309576SglebiusFrench Revolutionary calendar used 1793-11-24 through 1805-12-31, 630309576Sglebiusand (in Paris only) 1871-05-06 through 1871-05-23. 631309576Sglebius 632309576Sglebius 633309576SglebiusRussia 634309576Sglebius 635309576SglebiusFrom Chris Carrier (1996-12-02): 636309576SglebiusOn 1929-10-01 the Soviet Union instituted an "Eternal Calendar" 637309576Sglebiuswith 30-day months plus 5 holidays, with a 5-day week. 638309576SglebiusOn 1931-12-01 it changed to a 6-day week; in 1934 it reverted to the 639309576SglebiusGregorian calendar while retaining the 6-day week; on 1940-06-27 it 640309576Sglebiusreverted to the 7-day week. With the 6-day week the usual days 641309576Sglebiusoff were the 6th, 12th, 18th, 24th and 30th of the month. 642309576Sglebius(Source: Evitiar Zerubavel, _The Seven Day Circle_) 643309576Sglebius 644309576Sglebius 645309576SglebiusMark Brader reported a similar story in "The Book of Calendars", edited 646309576Sglebiusby Frank Parise (1982, Facts on File, ISBN 0-8719-6467-8), page 377. But: 647309576Sglebius 648309576SglebiusFrom: Petteri Sulonen (via Usenet) 649309576SglebiusDate: 14 Jan 1999 00:00:00 GMT 650309576Sglebius... 651309576Sglebius 652309576SglebiusIf your source is correct, how come documents between 1929 and 1940 were 653309576Sglebiusstill dated using the conventional, Gregorian calendar? 654309576Sglebius 655309576SglebiusI can post a scan of a document dated December 1, 1934, signed by 656309576SglebiusYenukidze, the secretary, on behalf of Kalinin, the President of the 657309576SglebiusExecutive Committee of the Supreme Soviet, if you like. 658309576Sglebius 659309576Sglebius 660309576Sglebius 661309576SglebiusSweden (and Finland) 662309576Sglebius 663309576SglebiusFrom: Mark Brader 664309576SglebiusSubject: Re: Gregorian reform - a part of locale? 665309576Sglebius<news:1996Jul6.012937.29190@sq.com> 666309576SglebiusDate: 1996-07-06 667309576Sglebius 668309576SglebiusIn 1700, Denmark made the transition from Julian to Gregorian. Sweden 669309576Sglebiusdecided to *start* a transition in 1700 as well, but rather than have one of 670309576Sglebiusthose unsightly calendar gaps :-), they simply decreed that the next leap 671309576Sglebiusyear after 1696 would be in 1744 - putting the whole country on a calendar 672309576Sglebiusdifferent from both Julian and Gregorian for a period of 40 years. 673309576Sglebius 674309576SglebiusHowever, in 1704 something went wrong and the plan was not carried through; 675309576Sglebiusthey did, after all, have a leap year that year. And one in 1708. In 1712 676309576Sglebiusthey gave it up and went back to Julian, putting 30 days in February that 677309576Sglebiusyear!... 678309576Sglebius 679309576SglebiusThen in 1753, Sweden made the transition to Gregorian in the usual manner, 680309576Sglebiusgetting there only 13 years behind the original schedule. 681309576Sglebius 682309576Sglebius(A previous posting of this story was challenged, and Swedish readers 683309576Sglebiusproduced the following references to support it: "Tider��kning och historia" 684309576Sglebiusby Natanael Beckman (1924) and "Tid, en bok om tider��kning och 685309576Sglebiuskalenderv��sen" by Lars-Olof Lod��n (1968). 686309576Sglebius 687309576Sglebius 688309576SglebiusGrotefend's data 689309576Sglebius 690309576SglebiusFrom: "Michael Palmer" [with one obvious typo fixed] 691309576SglebiusSubject: Re: Gregorian Calendar (was Re: Another FHC related question 692309576SglebiusNewsgroups: soc.genealogy.german 693309576SglebiusDate: Tue, 9 Feb 1999 02:32:48 -800 694309576Sglebius... 695309576Sglebius 696309576SglebiusThe following is a(n incomplete) listing, arranged chronologically, of 697309576SglebiusEuropean states, with the date they converted from the Julian to the 698309576SglebiusGregorian calendar: 699309576Sglebius 700309576Sglebius04/15 Oct 1582 - Italy (with exceptions), Spain, Portugal, Poland (Roman 701309576Sglebius Catholics and Danzig only) 702309576Sglebius09/20 Dec 1582 - France, Lorraine 703309576Sglebius 704309576Sglebius21 Dec 1582/ 705309576Sglebius 01 Jan 1583 - Holland, Brabant, Flanders, Hennegau 706309576Sglebius10/21 Feb 1583 - bishopric of Liege (L��ttich) 707309576Sglebius13/24 Feb 1583 - bishopric of Augsburg 708309576Sglebius04/15 Oct 1583 - electorate of Trier 709309576Sglebius05/16 Oct 1583 - Bavaria, bishoprics of Freising, Eichstedt, Regensburg, 710309576Sglebius Salzburg, Brixen 711309576Sglebius13/24 Oct 1583 - Austrian Oberelsa�� and Breisgau 712309576Sglebius20/31 Oct 1583 - bishopric of Basel 713309576Sglebius02/13 Nov 1583 - duchy of J��lich-Berg 714309576Sglebius02/13 Nov 1583 - electorate and city of K��ln 715309576Sglebius04/15 Nov 1583 - bishopric of W��rzburg 716309576Sglebius11/22 Nov 1583 - electorate of Mainz 717309576Sglebius16/27 Nov 1583 - bishopric of Strassburg and the margraviate of Baden 718309576Sglebius17/28 Nov 1583 - bishopric of M��nster and duchy of Cleve 719309576Sglebius14/25 Dec 1583 - Steiermark 720309576Sglebius 721309576Sglebius06/17 Jan 1584 - Austria and Bohemia 722309576Sglebius11/22 Jan 1584 - Lucerne, Uri, Schwyz, Zug, Freiburg, Solothurn 723309576Sglebius12/23 Jan 1584 - Silesia and the Lausitz 724309576Sglebius22 Jan/ 725309576Sglebius 02 Feb 1584 - Hungary (legally on 21 Oct 1587) 726309576Sglebius Jun 1584 - Unterwalden 727309576Sglebius01/12 Jul 1584 - duchy of Westfalen 728309576Sglebius 729309576Sglebius16/27 Jun 1585 - bishopric of Paderborn 730309576Sglebius 731309576Sglebius14/25 Dec 1590 - Transylvania 732309576Sglebius 733309576Sglebius22 Aug/ 734309576Sglebius 02 Sep 1612 - duchy of Prussia 735309576Sglebius 736309576Sglebius13/24 Dec 1614 - Pfalz-Neuburg 737309576Sglebius 738309576Sglebius 1617 - duchy of Kurland (reverted to the Julian calendar in 739309576Sglebius 1796) 740309576Sglebius 741309576Sglebius 1624 - bishopric of Osnabr��ck 742309576Sglebius 743309576Sglebius 1630 - bishopric of Minden 744309576Sglebius 745309576Sglebius15/26 Mar 1631 - bishopric of Hildesheim 746309576Sglebius 747309576Sglebius 1655 - Kanton Wallis 748309576Sglebius 749309576Sglebius05/16 Feb 1682 - city of Strassburg 750309576Sglebius 751309576Sglebius18 Feb/ 752309576Sglebius 01 Mar 1700 - Protestant Germany (including Swedish possessions in 753309576Sglebius Germany), Denmark, Norway 754309576Sglebius30 Jun/ 755309576Sglebius 12 Jul 1700 - Gelderland, Zutphen 756309576Sglebius10 Nov/ 757309576Sglebius 12 Dec 1700 - Utrecht, Overijssel 758309576Sglebius 759309576Sglebius31 Dec 1700/ 760309576Sglebius 12 Jan 1701 - Friesland, Groningen, Z��rich, Bern, Basel, Geneva, 761309576Sglebius Turgau, and Schaffhausen 762309576Sglebius 763309576Sglebius 1724 - Glarus, Appenzell, and the city of St. Gallen 764309576Sglebius 765309576Sglebius01 Jan 1750 - Pisa and Florence 766309576Sglebius 767309576Sglebius02/14 Sep 1752 - Great Britain 768309576Sglebius 769309576Sglebius17 Feb/ 770309576Sglebius 01 Mar 1753 - Sweden 771309576Sglebius 772309576Sglebius1760-1812 - Graub��nden 773309576Sglebius 774309576SglebiusThe Russian empire (including Finland and the Baltic states) did not 775309576Sglebiusconvert to the Gregorian calendar until the Soviet revolution of 1917. 776309576Sglebius 777309576SglebiusSource: H. Grotefend, _Taschenbuch der Zeitrechnung des deutschen 778309576SglebiusMittelalters und der Neuzeit_, herausgegeben von Dr. O. Grotefend 779309576Sglebius(Hannover: Hahnsche Buchhandlung, 1941), pp. 26-28. 780309576Sglebius 781309576Sglebius 782309576Sglebius----- Time and time zones on Mars ----- 783309576Sglebius 784309576SglebiusSome people's work schedules use Mars time. Jet Propulsion Laboratory 785309576Sglebius(JPL) coordinators have kept Mars time on and off at least since 1997 786309576Sglebiusfor the Mars Pathfinder mission. Some of their family members have 787309576Sglebiusalso adapted to Mars time. Dozens of special Mars watches were built 788309576Sglebiusfor JPL workers who kept Mars time during the Mars Exploration 789309576SglebiusRovers mission (2004). These timepieces look like normal Seikos and 790309576SglebiusCitizens but use Mars seconds rather than terrestrial seconds. 791309576Sglebius 792309576SglebiusA Mars solar day is called a "sol" and has a mean period equal to 793309576Sglebiusabout 24 hours 39 minutes 35.244 seconds in terrestrial time. It is 794309576Sglebiusdivided into a conventional 24-hour clock, so each Mars second equals 795309576Sglebiusabout 1.02749125 terrestrial seconds. 796309576Sglebius 797309576SglebiusThe prime meridian of Mars goes through the center of the crater 798309576SglebiusAiry-0, named in honor of the British astronomer who built the 799309576SglebiusGreenwich telescope that defines Earth's prime meridian. Mean solar 800309576Sglebiustime on the Mars prime meridian is called Mars Coordinated Time (MTC). 801309576Sglebius 802309576SglebiusEach landed mission on Mars has adopted a different reference for 803309576Sglebiussolar time keeping, so there is no real standard for Mars time zones. 804309576SglebiusFor example, the Mars Exploration Rover project (2004) defined two 805309576Sglebiustime zones "Local Solar Time A" and "Local Solar Time B" for its two 806309576Sglebiusmissions, each zone designed so that its time equals local true solar 807309576Sglebiustime at approximately the middle of the nominal mission. Such a "time 808309576Sglebiuszone" is not particularly suited for any application other than the 809309576Sglebiusmission itself. 810309576Sglebius 811309576SglebiusMany calendars have been proposed for Mars, but none have achieved 812309576Sglebiuswide acceptance. Astronomers often use Mars Sol Date (MSD) which is a 813309576Sglebiussequential count of Mars solar days elapsed since about 1873-12-29 814309576Sglebius12:00 GMT. 815309576Sglebius 816309576SglebiusThe tz database does not currently support Mars time, but it is 817309576Sglebiusdocumented here in the hopes that support will be added eventually. 818309576Sglebius 819309576SglebiusSources: 820309576Sglebius 821309576SglebiusMichael Allison and Robert Schmunk, 822309576Sglebius"Technical Notes on Mars Solar Time as Adopted by the Mars24 Sunclock" 823309576Sglebius<http://www.giss.nasa.gov/tools/mars24/help/notes.html> (2012-08-08). 824309576Sglebius 825309576SglebiusJia-Rui Chong, "Workdays Fit for a Martian", Los Angeles Times 826309576Sglebius<http://articles.latimes.com/2004/jan/14/science/sci-marstime14> 827309576Sglebius(2004-01-14), pp A1, A20-A21. 828309576Sglebius 829309576SglebiusTom Chmielewski, "Jet Lag Is Worse on Mars", The Atlantic (2015-02-26) 830309576Sglebius<http://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/> 831309576Sglebius 832309576Sglebius----- 833309576Sglebius 834309576SglebiusThis file is in the public domain, so clarified as of 2009-05-17 by 835309576SglebiusArthur David Olson. 836309576Sglebius 837309576Sglebius----- 838309576SglebiusLocal Variables: 839309576Sglebiuscoding: utf-8 840309576SglebiusEnd: 841