1309574SglebiusTheory and pragmatics of the tz code and data 2309574Sglebius 3309574Sglebius 4309574Sglebius----- Outline ----- 5309574Sglebius 6309574Sglebius Scope of the tz database 7309574Sglebius Names of time zone rules 8309574Sglebius Time zone abbreviations 9309574Sglebius Accuracy of the tz database 10309574Sglebius Time and date functions 11309574Sglebius Calendrical issues 12309574Sglebius Time and time zones on Mars 13309574Sglebius 14309574Sglebius 15309574Sglebius----- Scope of the tz database ----- 16309574Sglebius 17309574SglebiusThe tz database attempts to record the history and predicted future of 18309574Sglebiusall computer-based clocks that track civil time. To represent this 19309574Sglebiusdata, the world is partitioned into regions whose clocks all agree 20309574Sglebiusabout time stamps that occur after the somewhat-arbitrary cutoff point 21309574Sglebiusof the POSIX Epoch (1970-01-01 00:00:00 UTC). For each such region, 22309574Sglebiusthe database records all known clock transitions, and labels the region 23309574Sglebiuswith a notable location. Although 1970 is a somewhat-arbitrary 24309574Sglebiuscutoff, there are significant challenges to moving the cutoff earlier 25309574Sglebiuseven by a decade or two, due to the wide variety of local practices 26309574Sglebiusbefore computer timekeeping became prevalent. 27309574Sglebius 28309574SglebiusClock transitions before 1970 are recorded for each such location, 29309574Sglebiusbecause most systems support time stamps before 1970 and could 30309574Sglebiusmisbehave if data entries were omitted for pre-1970 transitions. 31309574SglebiusHowever, the database is not designed for and does not suffice for 32309574Sglebiusapplications requiring accurate handling of all past times everywhere, 33309574Sglebiusas it would take far too much effort and guesswork to record all 34309574Sglebiusdetails of pre-1970 civil timekeeping. 35309574Sglebius 36309574SglebiusAs described below, reference source code for using the tz database is 37309574Sglebiusalso available. The tz code is upwards compatible with POSIX, an 38309574Sglebiusinternational standard for UNIX-like systems. As of this writing, the 39309574Sglebiuscurrent edition of POSIX is: 40309574Sglebius 41309574Sglebius The Open Group Base Specifications Issue 7 42309574Sglebius IEEE Std 1003.1, 2013 Edition 43309574Sglebius <http://pubs.opengroup.org/onlinepubs/9699919799/> 44309574Sglebius 45309574Sglebius 46309574Sglebius 47309574Sglebius----- Names of time zone rules ----- 48309574Sglebius 49309574SglebiusEach of the database's time zone rules has a unique name. 50309574SglebiusInexperienced users are not expected to select these names unaided. 51309574SglebiusDistributors should provide documentation and/or a simple selection 52309574Sglebiusinterface that explains the names; for one example, see the 'tzselect' 53309574Sglebiusprogram in the tz code. The Unicode Common Locale Data Repository 54309574Sglebius<http://cldr.unicode.org/> contains data that may be useful for other 55309574Sglebiusselection interfaces. 56309574Sglebius 57309574SglebiusThe time zone rule naming conventions attempt to strike a balance 58309574Sglebiusamong the following goals: 59309574Sglebius 60309574Sglebius * Uniquely identify every region where clocks have agreed since 1970. 61309574Sglebius This is essential for the intended use: static clocks keeping local 62309574Sglebius civil time. 63309574Sglebius 64309574Sglebius * Indicate to experts where that region is. 65309574Sglebius 66309574Sglebius * Be robust in the presence of political changes. For example, names 67309574Sglebius of countries are ordinarily not used, to avoid incompatibilities 68309574Sglebius when countries change their name (e.g. Zaire->Congo) or when 69309574Sglebius locations change countries (e.g. Hong Kong from UK colony to 70309574Sglebius China). 71309574Sglebius 72309574Sglebius * Be portable to a wide variety of implementations. 73309574Sglebius 74309574Sglebius * Use a consistent naming conventions over the entire world. 75309574Sglebius 76309574SglebiusNames normally have the form AREA/LOCATION, where AREA is the name 77309574Sglebiusof a continent or ocean, and LOCATION is the name of a specific 78309574Sglebiuslocation within that region. North and South America share the same 79309574Sglebiusarea, 'America'. Typical names are 'Africa/Cairo', 'America/New_York', 80309574Sglebiusand 'Pacific/Honolulu'. 81309574Sglebius 82309574SglebiusHere are the general rules used for choosing location names, 83309574Sglebiusin decreasing order of importance: 84309574Sglebius 85309574Sglebius Use only valid POSIX file name components (i.e., the parts of 86309574Sglebius names other than '/'). Do not use the file name 87309574Sglebius components '.' and '..'. Within a file name component, 88309574Sglebius use only ASCII letters, '.', '-' and '_'. Do not use 89309574Sglebius digits, as that might create an ambiguity with POSIX 90309574Sglebius TZ strings. A file name component must not exceed 14 91309574Sglebius characters or start with '-'. E.g., prefer 'Brunei' 92309574Sglebius to 'Bandar_Seri_Begawan'. Exceptions: see the discussion 93309574Sglebius of legacy names below. 94309574Sglebius A name must not be empty, or contain '//', or start or end with '/'. 95309574Sglebius Do not use names that differ only in case. Although the reference 96309574Sglebius implementation is case-sensitive, some other implementations 97309574Sglebius are not, and they would mishandle names differing only in case. 98309574Sglebius If one name A is an initial prefix of another name AB (ignoring case), 99309574Sglebius then B must not start with '/', as a regular file cannot have 100309574Sglebius the same name as a directory in POSIX. For example, 101309574Sglebius 'America/New_York' precludes 'America/New_York/Bronx'. 102309574Sglebius Uninhabited regions like the North Pole and Bouvet Island 103309574Sglebius do not need locations, since local time is not defined there. 104309574Sglebius There should typically be at least one name for each ISO 3166-1 105309574Sglebius officially assigned two-letter code for an inhabited country 106309574Sglebius or territory. 107309574Sglebius If all the clocks in a region have agreed since 1970, 108309574Sglebius don't bother to include more than one location 109309574Sglebius even if subregions' clocks disagreed before 1970. 110309574Sglebius Otherwise these tables would become annoyingly large. 111309574Sglebius If a name is ambiguous, use a less ambiguous alternative; 112309574Sglebius e.g. many cities are named San Jos�� and Georgetown, so 113309574Sglebius prefer 'Costa_Rica' to 'San_Jose' and 'Guyana' to 'Georgetown'. 114309574Sglebius Keep locations compact. Use cities or small islands, not countries 115309574Sglebius or regions, so that any future time zone changes do not split 116309574Sglebius locations into different time zones. E.g. prefer 'Paris' 117309574Sglebius to 'France', since France has had multiple time zones. 118309574Sglebius Use mainstream English spelling, e.g. prefer 'Rome' to 'Roma', and 119309574Sglebius prefer 'Athens' to the Greek '����������' or the Romanized 'Ath��na'. 120309574Sglebius The POSIX file name restrictions encourage this rule. 121309574Sglebius Use the most populous among locations in a zone, 122309574Sglebius e.g. prefer 'Shanghai' to 'Beijing'. Among locations with 123309574Sglebius similar populations, pick the best-known location, 124309574Sglebius e.g. prefer 'Rome' to 'Milan'. 125309574Sglebius Use the singular form, e.g. prefer 'Canary' to 'Canaries'. 126309574Sglebius Omit common suffixes like '_Islands' and '_City', unless that 127309574Sglebius would lead to ambiguity. E.g. prefer 'Cayman' to 128309574Sglebius 'Cayman_Islands' and 'Guatemala' to 'Guatemala_City', 129309574Sglebius but prefer 'Mexico_City' to 'Mexico' because the country 130309574Sglebius of Mexico has several time zones. 131309574Sglebius Use '_' to represent a space. 132309574Sglebius Omit '.' from abbreviations in names, e.g. prefer 'St_Helena' 133309574Sglebius to 'St._Helena'. 134309574Sglebius Do not change established names if they only marginally 135309574Sglebius violate the above rules. For example, don't change 136309574Sglebius the existing name 'Rome' to 'Milan' merely because 137309574Sglebius Milan's population has grown to be somewhat greater 138309574Sglebius than Rome's. 139309574Sglebius If a name is changed, put its old spelling in the 'backward' file. 140309574Sglebius This means old spellings will continue to work. 141309574Sglebius 142309574SglebiusThe file 'zone1970.tab' lists geographical locations used to name time 143309574Sglebiuszone rules. It is intended to be an exhaustive list of names for 144309574Sglebiusgeographic regions as described above; this is a subset of the names 145309574Sglebiusin the data. Although a 'zone1970.tab' location's longitude 146309574Sglebiuscorresponds to its LMT offset with one hour for every 15 degrees east 147309574Sglebiuslongitude, this relationship is not exact. 148309574Sglebius 149309574SglebiusOlder versions of this package used a different naming scheme, 150309574Sglebiusand these older names are still supported. 151309574SglebiusSee the file 'backward' for most of these older names 152309574Sglebius(e.g., 'US/Eastern' instead of 'America/New_York'). 153309574SglebiusThe other old-fashioned names still supported are 154309574Sglebius'WET', 'CET', 'MET', and 'EET' (see the file 'europe'). 155309574Sglebius 156309574SglebiusOlder versions of this package defined legacy names that are 157309574Sglebiusincompatible with the first rule of location names, but which are 158309574Sglebiusstill supported. These legacy names are mostly defined in the file 159309574Sglebius'etcetera'. Also, the file 'backward' defines the legacy names 160309574Sglebius'GMT0', 'GMT-0', 'GMT+0' and 'Canada/East-Saskatchewan', and the file 161309574Sglebius'northamerica' defines the legacy names 'EST5EDT', 'CST6CDT', 162309574Sglebius'MST7MDT', and 'PST8PDT'. 163309574Sglebius 164309574SglebiusExcluding 'backward' should not affect the other data. If 165309574Sglebius'backward' is excluded, excluding 'etcetera' should not affect the 166309574Sglebiusremaining data. 167309574Sglebius 168309574Sglebius 169309574Sglebius----- Time zone abbreviations ----- 170309574Sglebius 171309574SglebiusWhen this package is installed, it generates time zone abbreviations 172309574Sglebiuslike 'EST' to be compatible with human tradition and POSIX. 173309574SglebiusHere are the general rules used for choosing time zone abbreviations, 174309574Sglebiusin decreasing order of importance: 175309574Sglebius 176309574Sglebius Use three or more characters that are ASCII alphanumerics or '+' or '-'. 177309574Sglebius Previous editions of this database also used characters like 178309574Sglebius ' ' and '?', but these characters have a special meaning to 179309574Sglebius the shell and cause commands like 180309574Sglebius set `date` 181309574Sglebius to have unexpected effects. 182309574Sglebius Previous editions of this rule required upper-case letters, 183309574Sglebius but the Congressman who introduced Chamorro Standard Time 184309574Sglebius preferred "ChST", so lower-case letters are now allowed. 185309574Sglebius Also, POSIX from 2001 on relaxed the rule to allow '-', '+', 186309574Sglebius and alphanumeric characters from the portable character set 187309574Sglebius in the current locale. In practice ASCII alphanumerics and 188309574Sglebius '+' and '-' are safe in all locales. 189309574Sglebius 190309574Sglebius In other words, in the C locale the POSIX extended regular 191309574Sglebius expression [-+[:alnum:]]{3,} should match the abbreviation. 192309574Sglebius This guarantees that all abbreviations could have been 193309574Sglebius specified by a POSIX TZ string. 194309574Sglebius 195309574Sglebius Use abbreviations that are in common use among English-speakers, 196309574Sglebius e.g. 'EST' for Eastern Standard Time in North America. 197309574Sglebius We assume that applications translate them to other languages 198309574Sglebius as part of the normal localization process; for example, 199309574Sglebius a French application might translate 'EST' to 'HNE'. 200309574Sglebius 201309574Sglebius For zones whose times are taken from a city's longitude, use the 202309574Sglebius traditional xMT notation, e.g. 'PMT' for Paris Mean Time. 203309574Sglebius The only name like this in current use is 'GMT'. 204309574Sglebius 205309574Sglebius Use 'LMT' for local mean time of locations before the introduction 206309574Sglebius of standard time; see "Scope of the tz database". 207309574Sglebius 208309574Sglebius If there is no common English abbreviation, use numeric offsets like 209309574Sglebius -05 and +0830 that are generated by zic's %z notation. 210309574Sglebius 211309574Sglebius [The remaining guidelines predate the introduction of %z. 212309574Sglebius They are problematic as they mean tz data entries invent 213309574Sglebius notation rather than record it. These guidelines are now 214309574Sglebius deprecated and the plan is to gradually move to %z for 215309574Sglebius inhabited locations and to "-00" for uninhabited locations.] 216309574Sglebius 217309574Sglebius If there is no common English abbreviation, abbreviate the English 218309574Sglebius translation of the usual phrase used by native speakers. 219309574Sglebius If this is not available or is a phrase mentioning the country 220309574Sglebius (e.g. "Cape Verde Time"), then: 221309574Sglebius 222309574Sglebius When a country is identified with a single or principal zone, 223309574Sglebius append 'T' to the country's ISO code, e.g. 'CVT' for 224309574Sglebius Cape Verde Time. For summer time append 'ST'; 225309574Sglebius for double summer time append 'DST'; etc. 226309574Sglebius Otherwise, take the first three letters of an English place 227309574Sglebius name identifying each zone and append 'T', 'ST', etc. 228309574Sglebius as before; e.g. 'VLAST' for VLAdivostok Summer Time. 229309574Sglebius 230309574Sglebius Use UT (with time zone abbreviation '-00') for locations while 231309574Sglebius uninhabited. The leading '-' is a flag that the time 232309574Sglebius zone is in some sense undefined; this notation is 233309574Sglebius derived from Internet RFC 3339. 234309574Sglebius 235309574SglebiusApplication writers should note that these abbreviations are ambiguous 236309574Sglebiusin practice: e.g. 'CST' has a different meaning in China than 237309574Sglebiusit does in the United States. In new applications, it's often better 238309574Sglebiusto use numeric UT offsets like '-0600' instead of time zone 239309574Sglebiusabbreviations like 'CST'; this avoids the ambiguity. 240309574Sglebius 241309574Sglebius 242309574Sglebius----- Accuracy of the tz database ----- 243309574Sglebius 244309574SglebiusThe tz database is not authoritative, and it surely has errors. 245309574SglebiusCorrections are welcome and encouraged; see the file CONTRIBUTING. 246309574SglebiusUsers requiring authoritative data should consult national standards 247309574Sglebiusbodies and the references cited in the database's comments. 248309574Sglebius 249309574SglebiusErrors in the tz database arise from many sources: 250309574Sglebius 251309574Sglebius * The tz database predicts future time stamps, and current predictions 252309574Sglebius will be incorrect after future governments change the rules. 253309574Sglebius For example, if today someone schedules a meeting for 13:00 next 254309574Sglebius October 1, Casablanca time, and tomorrow Morocco changes its 255309574Sglebius daylight saving rules, software can mess up after the rule change 256309574Sglebius if it blithely relies on conversions made before the change. 257309574Sglebius 258309574Sglebius * The pre-1970 entries in this database cover only a tiny sliver of how 259309574Sglebius clocks actually behaved; the vast majority of the necessary 260309574Sglebius information was lost or never recorded. Thousands more zones would 261309574Sglebius be needed if the tz database's scope were extended to cover even 262309574Sglebius just the known or guessed history of standard time; for example, 263309574Sglebius the current single entry for France would need to split into dozens 264309574Sglebius of entries, perhaps hundreds. And in most of the world even this 265309574Sglebius approach would be misleading due to widespread disagreement or 266309574Sglebius indifference about what times should be observed. In her 2015 book 267309574Sglebius "The Global Transformation of Time, 1870-1950", Vanessa Ogle writes 268309574Sglebius "Outside of Europe and North America there was no system of time 269309574Sglebius zones at all, often not even a stable landscape of mean times, 270309574Sglebius prior to the middle decades of the twentieth century". See: 271309574Sglebius Timothy Shenk, Booked: A Global History of Time. Dissent 2015-12-17 272309574Sglebius https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle 273309574Sglebius 274309574Sglebius * Most of the pre-1970 data entries come from unreliable sources, often 275309574Sglebius astrology books that lack citations and whose compilers evidently 276309574Sglebius invented entries when the true facts were unknown, without 277309574Sglebius reporting which entries were known and which were invented. 278309574Sglebius These books often contradict each other or give implausible entries, 279309574Sglebius and on the rare occasions when they are checked they are 280309574Sglebius typically found to be incorrect. 281309574Sglebius 282309574Sglebius * For the UK the tz database relies on years of first-class work done by 283309574Sglebius Joseph Myers and others; see <http://www.polyomino.org.uk/british-time/>. 284309574Sglebius Other countries are not done nearly as well. 285309574Sglebius 286309574Sglebius * Sometimes, different people in the same city would maintain clocks 287309574Sglebius that differed significantly. Railway time was used by railroad 288309574Sglebius companies (which did not always agree with each other), 289309574Sglebius church-clock time was used for birth certificates, etc. 290309574Sglebius Often this was merely common practice, but sometimes it was set by law. 291309574Sglebius For example, from 1891 to 1911 the UT offset in France was legally 292309574Sglebius 0:09:21 outside train stations and 0:04:21 inside. 293309574Sglebius 294309574Sglebius * Although a named location in the tz database stands for the 295309574Sglebius containing region, its pre-1970 data entries are often accurate for 296309574Sglebius only a small subset of that region. For example, Europe/London 297309574Sglebius stands for the United Kingdom, but its pre-1847 times are valid 298309574Sglebius only for locations that have London's exact meridian, and its 1847 299309574Sglebius transition to GMT is known to be valid only for the L&NW and the 300309574Sglebius Caledonian railways. 301309574Sglebius 302309574Sglebius * The tz database does not record the earliest time for which a zone's 303309574Sglebius data entries are thereafter valid for every location in the region. 304309574Sglebius For example, Europe/London is valid for all locations in its 305309574Sglebius region after GMT was made the standard time, but the date of 306309574Sglebius standardization (1880-08-02) is not in the tz database, other than 307309574Sglebius in commentary. For many zones the earliest time of validity is 308309574Sglebius unknown. 309309574Sglebius 310309574Sglebius * The tz database does not record a region's boundaries, and in many 311309574Sglebius cases the boundaries are not known. For example, the zone 312309574Sglebius America/Kentucky/Louisville represents a region around the city of 313309574Sglebius Louisville, the boundaries of which are unclear. 314309574Sglebius 315309574Sglebius * Changes that are modeled as instantaneous transitions in the tz 316309574Sglebius database were often spread out over hours, days, or even decades. 317309574Sglebius 318309574Sglebius * Even if the time is specified by law, locations sometimes 319309574Sglebius deliberately flout the law. 320309574Sglebius 321309574Sglebius * Early timekeeping practices, even assuming perfect clocks, were 322309574Sglebius often not specified to the accuracy that the tz database requires. 323309574Sglebius 324309574Sglebius * Sometimes historical timekeeping was specified more precisely 325309574Sglebius than what the tz database can handle. For example, from 1909 to 326309574Sglebius 1937 Netherlands clocks were legally UT +00:19:32.13, but the tz 327309574Sglebius database cannot represent the fractional second. 328309574Sglebius 329309574Sglebius * Even when all the timestamp transitions recorded by the tz database 330309574Sglebius are correct, the tz rules that generate them may not faithfully 331309574Sglebius reflect the historical rules. For example, from 1922 until World 332309574Sglebius War II the UK moved clocks forward the day following the third 333309574Sglebius Saturday in April unless that was Easter, in which case it moved 334309574Sglebius clocks forward the previous Sunday. Because the tz database has no 335309574Sglebius way to specify Easter, these exceptional years are entered as 336309574Sglebius separate tz Rule lines, even though the legal rules did not change. 337309574Sglebius 338309574Sglebius * The tz database models pre-standard time using the proleptic Gregorian 339309574Sglebius calendar and local mean time (LMT), but many people used other 340309574Sglebius calendars and other timescales. For example, the Roman Empire used 341309574Sglebius the Julian calendar, and had 12 varying-length daytime hours with a 342309574Sglebius non-hour-based system at night. 343309574Sglebius 344309574Sglebius * Early clocks were less reliable, and data entries do not represent 345309574Sglebius this unreliability. 346309574Sglebius 347309574Sglebius * As for leap seconds, civil time was not based on atomic time before 348309574Sglebius 1972, and we don't know the history of earth's rotation accurately 349309574Sglebius enough to map SI seconds to historical solar time to more than 350309574Sglebius about one-hour accuracy. See: Morrison LV, Stephenson FR. 351309574Sglebius Historical values of the Earth's clock error Delta T and the 352309574Sglebius calculation of eclipses. J Hist Astron. 2004;35:327-36 353309574Sglebius <http://adsabs.harvard.edu/full/2004JHA....35..327M>; 354309574Sglebius Historical values of the Earth's clock error. J Hist Astron. 2005;36:339 355309574Sglebius <http://adsabs.harvard.edu/full/2005JHA....36..339M>. 356309574Sglebius 357309574Sglebius * The relationship between POSIX time (that is, UTC but ignoring leap 358309574Sglebius seconds) and UTC is not agreed upon after 1972. Although the POSIX 359309574Sglebius clock officially stops during an inserted leap second, at least one 360309574Sglebius proposed standard has it jumping back a second instead; and in 361309574Sglebius practice POSIX clocks more typically either progress glacially during 362309574Sglebius a leap second, or are slightly slowed while near a leap second. 363309574Sglebius 364309574Sglebius * The tz database does not represent how uncertain its information is. 365309574Sglebius Ideally it would contain information about when data entries are 366309574Sglebius incomplete or dicey. Partial temporal knowledge is a field of 367309574Sglebius active research, though, and it's not clear how to apply it here. 368309574Sglebius 369309574SglebiusIn short, many, perhaps most, of the tz database's pre-1970 and future 370309574Sglebiustime stamps are either wrong or misleading. Any attempt to pass the 371309574Sglebiustz database off as the definition of time should be unacceptable to 372309574Sglebiusanybody who cares about the facts. In particular, the tz database's 373309574SglebiusLMT offsets should not be considered meaningful, and should not prompt 374309574Sglebiuscreation of zones merely because two locations differ in LMT or 375309574Sglebiustransitioned to standard time at different dates. 376309574Sglebius 377309574Sglebius 378309574Sglebius----- Time and date functions ----- 379309574Sglebius 380309574SglebiusThe tz code contains time and date functions that are upwards 381309574Sglebiuscompatible with those of POSIX. 382309574Sglebius 383309574SglebiusPOSIX has the following properties and limitations. 384309574Sglebius 385309574Sglebius* In POSIX, time display in a process is controlled by the 386309574Sglebius environment variable TZ. Unfortunately, the POSIX TZ string takes 387309574Sglebius a form that is hard to describe and is error-prone in practice. 388309574Sglebius Also, POSIX TZ strings can't deal with other (for example, Israeli) 389309574Sglebius daylight saving time rules, or situations where more than two 390309574Sglebius time zone abbreviations are used in an area. 391309574Sglebius 392309574Sglebius The POSIX TZ string takes the following form: 393309574Sglebius 394309574Sglebius stdoffset[dst[offset][,date[/time],date[/time]]] 395309574Sglebius 396309574Sglebius where: 397309574Sglebius 398309574Sglebius std and dst 399309574Sglebius are 3 or more characters specifying the standard 400309574Sglebius and daylight saving time (DST) zone names. 401309574Sglebius Starting with POSIX.1-2001, std and dst may also be 402309574Sglebius in a quoted form like "<UTC+10>"; this allows 403309574Sglebius "+" and "-" in the names. 404309574Sglebius offset 405309574Sglebius is of the form '[+-]hh:[mm[:ss]]' and specifies the 406309574Sglebius offset west of UT. 'hh' may be a single digit; 0<=hh<=24. 407309574Sglebius The default DST offset is one hour ahead of standard time. 408309574Sglebius date[/time],date[/time] 409309574Sglebius specifies the beginning and end of DST. If this is absent, 410309574Sglebius the system supplies its own rules for DST, and these can 411309574Sglebius differ from year to year; typically US DST rules are used. 412309574Sglebius time 413309574Sglebius takes the form 'hh:[mm[:ss]]' and defaults to 02:00. 414309574Sglebius This is the same format as the offset, except that a 415309574Sglebius leading '+' or '-' is not allowed. 416309574Sglebius date 417309574Sglebius takes one of the following forms: 418309574Sglebius Jn (1<=n<=365) 419309574Sglebius origin-1 day number not counting February 29 420309574Sglebius n (0<=n<=365) 421309574Sglebius origin-0 day number counting February 29 if present 422309574Sglebius Mm.n.d (0[Sunday]<=d<=6[Saturday], 1<=n<=5, 1<=m<=12) 423309574Sglebius for the dth day of week n of month m of the year, 424309574Sglebius where week 1 is the first week in which day d appears, 425309574Sglebius and '5' stands for the last week in which day d appears 426309574Sglebius (which may be either the 4th or 5th week). 427309574Sglebius Typically, this is the only useful form; 428309574Sglebius the n and Jn forms are rarely used. 429309574Sglebius 430309574Sglebius Here is an example POSIX TZ string, for US Pacific time using rules 431309574Sglebius appropriate from 1987 through 2006: 432309574Sglebius 433309574Sglebius TZ='PST8PDT,M4.1.0/02:00,M10.5.0/02:00' 434309574Sglebius 435309574Sglebius This POSIX TZ string is hard to remember, and mishandles time stamps 436309574Sglebius before 1987 and after 2006. With this package you can use this 437309574Sglebius instead: 438309574Sglebius 439309574Sglebius TZ='America/Los_Angeles' 440309574Sglebius 441309574Sglebius* POSIX does not define the exact meaning of TZ values like "EST5EDT". 442309574Sglebius Typically the current US DST rules are used to interpret such values, 443309574Sglebius but this means that the US DST rules are compiled into each program 444309574Sglebius that does time conversion. This means that when US time conversion 445309574Sglebius rules change (as in the United States in 1987), all programs that 446309574Sglebius do time conversion must be recompiled to ensure proper results. 447309574Sglebius 448309574Sglebius* The TZ environment variable is process-global, which makes it hard 449309574Sglebius to write efficient, thread-safe applications that need access 450309574Sglebius to multiple time zones. 451309574Sglebius 452309574Sglebius* In POSIX, there's no tamper-proof way for a process to learn the 453309574Sglebius system's best idea of local wall clock. (This is important for 454309574Sglebius applications that an administrator wants used only at certain times - 455309574Sglebius without regard to whether the user has fiddled the "TZ" environment 456309574Sglebius variable. While an administrator can "do everything in UTC" to get 457309574Sglebius around the problem, doing so is inconvenient and precludes handling 458309574Sglebius daylight saving time shifts - as might be required to limit phone 459309574Sglebius calls to off-peak hours.) 460309574Sglebius 461309574Sglebius* POSIX provides no convenient and efficient way to determine the UT 462309574Sglebius offset and time zone abbreviation of arbitrary time stamps, 463309574Sglebius particularly for time zone settings that do not fit into the 464309574Sglebius POSIX model. 465309574Sglebius 466309574Sglebius* POSIX requires that systems ignore leap seconds. 467309574Sglebius 468309574Sglebius* The tz code attempts to support all the time_t implementations 469309574Sglebius allowed by POSIX. The time_t type represents a nonnegative count of 470309574Sglebius seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds. 471309574Sglebius In practice, time_t is usually a signed 64- or 32-bit integer; 32-bit 472309574Sglebius signed time_t values stop working after 2038-01-19 03:14:07 UTC, so 473309574Sglebius new implementations these days typically use a signed 64-bit integer. 474309574Sglebius Unsigned 32-bit integers are used on one or two platforms, 475309574Sglebius and 36-bit and 40-bit integers are also used occasionally. 476309574Sglebius Although earlier POSIX versions allowed time_t to be a 477309574Sglebius floating-point type, this was not supported by any practical 478309574Sglebius systems, and POSIX.1-2013 and the tz code both require time_t 479309574Sglebius to be an integer type. 480309574Sglebius 481309574SglebiusThese are the extensions that have been made to the POSIX functions: 482309574Sglebius 483309574Sglebius* The "TZ" environment variable is used in generating the name of a file 484309574Sglebius from which time zone information is read (or is interpreted a la 485309574Sglebius POSIX); "TZ" is no longer constrained to be a three-letter time zone 486309574Sglebius name followed by a number of hours and an optional three-letter 487309574Sglebius daylight time zone name. The daylight saving time rules to be used 488309574Sglebius for a particular time zone are encoded in the time zone file; 489309574Sglebius the format of the file allows U.S., Australian, and other rules to be 490309574Sglebius encoded, and allows for situations where more than two time zone 491309574Sglebius abbreviations are used. 492309574Sglebius 493309574Sglebius It was recognized that allowing the "TZ" environment variable to 494309574Sglebius take on values such as "America/New_York" might cause "old" programs 495309574Sglebius (that expect "TZ" to have a certain form) to operate incorrectly; 496309574Sglebius consideration was given to using some other environment variable 497309574Sglebius (for example, "TIMEZONE") to hold the string used to generate the 498309574Sglebius time zone information file name. In the end, however, it was decided 499309574Sglebius to continue using "TZ": it is widely used for time zone purposes; 500309574Sglebius separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance; 501309574Sglebius and systems where "new" forms of "TZ" might cause problems can simply 502309574Sglebius use TZ values such as "EST5EDT" which can be used both by 503309574Sglebius "new" programs (a la POSIX) and "old" programs (as zone names and 504309574Sglebius offsets). 505309574Sglebius 506309574Sglebius* The code supports platforms with a UT offset member in struct tm, 507309574Sglebius e.g., tm_gmtoff. 508309574Sglebius 509309574Sglebius* The code supports platforms with a time zone abbreviation member in 510309574Sglebius struct tm, e.g., tm_zone. 511309574Sglebius 512309574Sglebius* Since the "TZ" environment variable can now be used to control time 513309574Sglebius conversion, the "daylight" and "timezone" variables are no longer 514309574Sglebius needed. (These variables are defined and set by "tzset"; however, their 515309574Sglebius values will not be used by "localtime.") 516309574Sglebius 517309574Sglebius* Functions tzalloc, tzfree, localtime_rz, and mktime_z for 518309574Sglebius more-efficient thread-safe applications that need to use 519309574Sglebius multiple time zones. The tzalloc and tzfree functions 520309574Sglebius allocate and free objects of type timezone_t, and localtime_rz 521309574Sglebius and mktime_z are like localtime_r and mktime with an extra 522309574Sglebius timezone_t argument. The functions were inspired by NetBSD. 523309574Sglebius 524309574Sglebius* A function "tzsetwall" has been added to arrange for the system's 525309574Sglebius best approximation to local wall clock time to be delivered by 526309574Sglebius subsequent calls to "localtime." Source code for portable 527309574Sglebius applications that "must" run on local wall clock time should call 528309574Sglebius "tzsetwall();" if such code is moved to "old" systems that don't 529309574Sglebius provide tzsetwall, you won't be able to generate an executable program. 530309574Sglebius (These time zone functions also arrange for local wall clock time to be 531309574Sglebius used if tzset is called - directly or indirectly - and there's no "TZ" 532309574Sglebius environment variable; portable applications should not, however, rely 533309574Sglebius on this behavior since it's not the way SVR2 systems behave.) 534309574Sglebius 535309574Sglebius* Negative time_t values are supported, on systems where time_t is signed. 536309574Sglebius 537309574Sglebius* These functions can account for leap seconds, thanks to Bradley White. 538309574Sglebius 539309574SglebiusPoints of interest to folks with other systems: 540309574Sglebius 541309574Sglebius* Code compatible with this package is already part of many platforms, 542309574Sglebius including GNU/Linux, Android, the BSDs, Chromium OS, Cygwin, AIX, iOS, 543309574Sglebius BlackBery 10, macOS, Microsoft Windows, OpenVMS, and Solaris. 544309574Sglebius On such hosts, the primary use of this package 545309574Sglebius is to update obsolete time zone rule tables. 546309574Sglebius To do this, you may need to compile the time zone compiler 547309574Sglebius 'zic' supplied with this package instead of using the system 'zic', 548309574Sglebius since the format of zic's input is occasionally extended, 549309574Sglebius and a platform may still be shipping an older zic. 550309574Sglebius 551309574Sglebius* The UNIX Version 7 "timezone" function is not present in this package; 552309574Sglebius it's impossible to reliably map timezone's arguments (a "minutes west 553309574Sglebius of GMT" value and a "daylight saving time in effect" flag) to a 554309574Sglebius time zone abbreviation, and we refuse to guess. 555309574Sglebius Programs that in the past used the timezone function may now examine 556309574Sglebius tzname[localtime(&clock)->tm_isdst] to learn the correct time 557309574Sglebius zone abbreviation to use. Alternatively, use 558309574Sglebius localtime(&clock)->tm_zone if this has been enabled. 559309574Sglebius 560309574Sglebius* The 4.2BSD gettimeofday function is not used in this package. 561309574Sglebius This formerly let users obtain the current UTC offset and DST flag, 562309574Sglebius but this functionality was removed in later versions of BSD. 563309574Sglebius 564309574Sglebius* In SVR2, time conversion fails for near-minimum or near-maximum 565309574Sglebius time_t values when doing conversions for places that don't use UT. 566309574Sglebius This package takes care to do these conversions correctly. 567309574Sglebius A comment in the source code tells how to get compatibly wrong 568309574Sglebius results. 569309574Sglebius 570309574SglebiusThe functions that are conditionally compiled if STD_INSPIRED is defined 571309574Sglebiusshould, at this point, be looked on primarily as food for thought. They are 572309574Sglebiusnot in any sense "standard compatible" - some are not, in fact, specified in 573309574Sglebius*any* standard. They do, however, represent responses of various authors to 574309574Sglebiusstandardization proposals. 575309574Sglebius 576309574SglebiusOther time conversion proposals, in particular the one developed by folks at 577309574SglebiusHewlett Packard, offer a wider selection of functions that provide capabilities 578309574Sglebiusbeyond those provided here. The absence of such functions from this package 579309574Sglebiusis not meant to discourage the development, standardization, or use of such 580309574Sglebiusfunctions. Rather, their absence reflects the decision to make this package 581309574Sglebiuscontain valid extensions to POSIX, to ensure its broad acceptability. If 582309574Sglebiusmore powerful time conversion functions can be standardized, so much the 583309574Sglebiusbetter. 584309574Sglebius 585309574Sglebius 586309574Sglebius----- Interface stability ----- 587309574Sglebius 588309574SglebiusThe tz code and data supply the following interfaces: 589309574Sglebius 590309574Sglebius * A set of zone names as per "Names of time zone rules" above. 591309574Sglebius 592309574Sglebius * Library functions described in "Time and date functions" above. 593309574Sglebius 594309574Sglebius * The programs tzselect, zdump, and zic, documented in their man pages. 595309574Sglebius 596309574Sglebius * The format of zic input files, documented in the zic man page. 597309574Sglebius 598309574Sglebius * The format of zic output files, documented in the tzfile man page. 599309574Sglebius 600309574Sglebius * The format of zone table files, documented in zone1970.tab. 601309574Sglebius 602309574Sglebius * The format of the country code file, documented in iso3166.tab. 603309574Sglebius 604309574SglebiusWhen these interfaces are changed, an effort is made to preserve 605309574Sglebiusbackward compatibility. For example, tz data files typically do not 606309574Sglebiusrely on recently-added zic features, so that users can run older zic 607309574Sglebiusversions to process newer data files. 608309574Sglebius 609309574SglebiusInterfaces not listed above are less stable. For example, users 610309574Sglebiusshould not rely on particular UT offsets or abbreviations for time 611309574Sglebiusstamps, as data entries are often based on guesswork and these guesses 612309574Sglebiusmay be corrected or improved. 613309574Sglebius 614309574Sglebius 615309574Sglebius----- Calendrical issues ----- 616309574Sglebius 617309574SglebiusCalendrical issues are a bit out of scope for a time zone database, 618309574Sglebiusbut they indicate the sort of problems that we would run into if we 619309574Sglebiusextended the time zone database further into the past. An excellent 620309574Sglebiusresource in this area is Nachum Dershowitz and Edward M. Reingold, 621309574SglebiusCalendrical Calculations: Third Edition, Cambridge University Press (2008) 622309574Sglebius<http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/>. 623309574SglebiusOther information and sources are given below. They sometimes disagree. 624309574Sglebius 625309574Sglebius 626309574SglebiusFrance 627309574Sglebius 628309574SglebiusGregorian calendar adopted 1582-12-20. 629309574SglebiusFrench Revolutionary calendar used 1793-11-24 through 1805-12-31, 630309574Sglebiusand (in Paris only) 1871-05-06 through 1871-05-23. 631309574Sglebius 632309574Sglebius 633309574SglebiusRussia 634309574Sglebius 635309574SglebiusFrom Chris Carrier (1996-12-02): 636309574SglebiusOn 1929-10-01 the Soviet Union instituted an "Eternal Calendar" 637309574Sglebiuswith 30-day months plus 5 holidays, with a 5-day week. 638309574SglebiusOn 1931-12-01 it changed to a 6-day week; in 1934 it reverted to the 639309574SglebiusGregorian calendar while retaining the 6-day week; on 1940-06-27 it 640309574Sglebiusreverted to the 7-day week. With the 6-day week the usual days 641309574Sglebiusoff were the 6th, 12th, 18th, 24th and 30th of the month. 642309574Sglebius(Source: Evitiar Zerubavel, _The Seven Day Circle_) 643309574Sglebius 644309574Sglebius 645309574SglebiusMark Brader reported a similar story in "The Book of Calendars", edited 646309574Sglebiusby Frank Parise (1982, Facts on File, ISBN 0-8719-6467-8), page 377. But: 647309574Sglebius 648309574SglebiusFrom: Petteri Sulonen (via Usenet) 649309574SglebiusDate: 14 Jan 1999 00:00:00 GMT 650309574Sglebius... 651309574Sglebius 652309574SglebiusIf your source is correct, how come documents between 1929 and 1940 were 653309574Sglebiusstill dated using the conventional, Gregorian calendar? 654309574Sglebius 655309574SglebiusI can post a scan of a document dated December 1, 1934, signed by 656309574SglebiusYenukidze, the secretary, on behalf of Kalinin, the President of the 657309574SglebiusExecutive Committee of the Supreme Soviet, if you like. 658309574Sglebius 659309574Sglebius 660309574Sglebius 661309574SglebiusSweden (and Finland) 662309574Sglebius 663309574SglebiusFrom: Mark Brader 664309574SglebiusSubject: Re: Gregorian reform - a part of locale? 665309574Sglebius<news:1996Jul6.012937.29190@sq.com> 666309574SglebiusDate: 1996-07-06 667309574Sglebius 668309574SglebiusIn 1700, Denmark made the transition from Julian to Gregorian. Sweden 669309574Sglebiusdecided to *start* a transition in 1700 as well, but rather than have one of 670309574Sglebiusthose unsightly calendar gaps :-), they simply decreed that the next leap 671309574Sglebiusyear after 1696 would be in 1744 - putting the whole country on a calendar 672309574Sglebiusdifferent from both Julian and Gregorian for a period of 40 years. 673309574Sglebius 674309574SglebiusHowever, in 1704 something went wrong and the plan was not carried through; 675309574Sglebiusthey did, after all, have a leap year that year. And one in 1708. In 1712 676309574Sglebiusthey gave it up and went back to Julian, putting 30 days in February that 677309574Sglebiusyear!... 678309574Sglebius 679309574SglebiusThen in 1753, Sweden made the transition to Gregorian in the usual manner, 680309574Sglebiusgetting there only 13 years behind the original schedule. 681309574Sglebius 682309574Sglebius(A previous posting of this story was challenged, and Swedish readers 683309574Sglebiusproduced the following references to support it: "Tider��kning och historia" 684309574Sglebiusby Natanael Beckman (1924) and "Tid, en bok om tider��kning och 685309574Sglebiuskalenderv��sen" by Lars-Olof Lod��n (1968). 686309574Sglebius 687309574Sglebius 688309574SglebiusGrotefend's data 689309574Sglebius 690309574SglebiusFrom: "Michael Palmer" [with one obvious typo fixed] 691309574SglebiusSubject: Re: Gregorian Calendar (was Re: Another FHC related question 692309574SglebiusNewsgroups: soc.genealogy.german 693309574SglebiusDate: Tue, 9 Feb 1999 02:32:48 -800 694309574Sglebius... 695309574Sglebius 696309574SglebiusThe following is a(n incomplete) listing, arranged chronologically, of 697309574SglebiusEuropean states, with the date they converted from the Julian to the 698309574SglebiusGregorian calendar: 699309574Sglebius 700309574Sglebius04/15 Oct 1582 - Italy (with exceptions), Spain, Portugal, Poland (Roman 701309574Sglebius Catholics and Danzig only) 702309574Sglebius09/20 Dec 1582 - France, Lorraine 703309574Sglebius 704309574Sglebius21 Dec 1582/ 705309574Sglebius 01 Jan 1583 - Holland, Brabant, Flanders, Hennegau 706309574Sglebius10/21 Feb 1583 - bishopric of Liege (L��ttich) 707309574Sglebius13/24 Feb 1583 - bishopric of Augsburg 708309574Sglebius04/15 Oct 1583 - electorate of Trier 709309574Sglebius05/16 Oct 1583 - Bavaria, bishoprics of Freising, Eichstedt, Regensburg, 710309574Sglebius Salzburg, Brixen 711309574Sglebius13/24 Oct 1583 - Austrian Oberelsa�� and Breisgau 712309574Sglebius20/31 Oct 1583 - bishopric of Basel 713309574Sglebius02/13 Nov 1583 - duchy of J��lich-Berg 714309574Sglebius02/13 Nov 1583 - electorate and city of K��ln 715309574Sglebius04/15 Nov 1583 - bishopric of W��rzburg 716309574Sglebius11/22 Nov 1583 - electorate of Mainz 717309574Sglebius16/27 Nov 1583 - bishopric of Strassburg and the margraviate of Baden 718309574Sglebius17/28 Nov 1583 - bishopric of M��nster and duchy of Cleve 719309574Sglebius14/25 Dec 1583 - Steiermark 720309574Sglebius 721309574Sglebius06/17 Jan 1584 - Austria and Bohemia 722309574Sglebius11/22 Jan 1584 - Lucerne, Uri, Schwyz, Zug, Freiburg, Solothurn 723309574Sglebius12/23 Jan 1584 - Silesia and the Lausitz 724309574Sglebius22 Jan/ 725309574Sglebius 02 Feb 1584 - Hungary (legally on 21 Oct 1587) 726309574Sglebius Jun 1584 - Unterwalden 727309574Sglebius01/12 Jul 1584 - duchy of Westfalen 728309574Sglebius 729309574Sglebius16/27 Jun 1585 - bishopric of Paderborn 730309574Sglebius 731309574Sglebius14/25 Dec 1590 - Transylvania 732309574Sglebius 733309574Sglebius22 Aug/ 734309574Sglebius 02 Sep 1612 - duchy of Prussia 735309574Sglebius 736309574Sglebius13/24 Dec 1614 - Pfalz-Neuburg 737309574Sglebius 738309574Sglebius 1617 - duchy of Kurland (reverted to the Julian calendar in 739309574Sglebius 1796) 740309574Sglebius 741309574Sglebius 1624 - bishopric of Osnabr��ck 742309574Sglebius 743309574Sglebius 1630 - bishopric of Minden 744309574Sglebius 745309574Sglebius15/26 Mar 1631 - bishopric of Hildesheim 746309574Sglebius 747309574Sglebius 1655 - Kanton Wallis 748309574Sglebius 749309574Sglebius05/16 Feb 1682 - city of Strassburg 750309574Sglebius 751309574Sglebius18 Feb/ 752309574Sglebius 01 Mar 1700 - Protestant Germany (including Swedish possessions in 753309574Sglebius Germany), Denmark, Norway 754309574Sglebius30 Jun/ 755309574Sglebius 12 Jul 1700 - Gelderland, Zutphen 756309574Sglebius10 Nov/ 757309574Sglebius 12 Dec 1700 - Utrecht, Overijssel 758309574Sglebius 759309574Sglebius31 Dec 1700/ 760309574Sglebius 12 Jan 1701 - Friesland, Groningen, Z��rich, Bern, Basel, Geneva, 761309574Sglebius Turgau, and Schaffhausen 762309574Sglebius 763309574Sglebius 1724 - Glarus, Appenzell, and the city of St. Gallen 764309574Sglebius 765309574Sglebius01 Jan 1750 - Pisa and Florence 766309574Sglebius 767309574Sglebius02/14 Sep 1752 - Great Britain 768309574Sglebius 769309574Sglebius17 Feb/ 770309574Sglebius 01 Mar 1753 - Sweden 771309574Sglebius 772309574Sglebius1760-1812 - Graub��nden 773309574Sglebius 774309574SglebiusThe Russian empire (including Finland and the Baltic states) did not 775309574Sglebiusconvert to the Gregorian calendar until the Soviet revolution of 1917. 776309574Sglebius 777309574SglebiusSource: H. Grotefend, _Taschenbuch der Zeitrechnung des deutschen 778309574SglebiusMittelalters und der Neuzeit_, herausgegeben von Dr. O. Grotefend 779309574Sglebius(Hannover: Hahnsche Buchhandlung, 1941), pp. 26-28. 780309574Sglebius 781309574Sglebius 782309574Sglebius----- Time and time zones on Mars ----- 783309574Sglebius 784309574SglebiusSome people's work schedules use Mars time. Jet Propulsion Laboratory 785309574Sglebius(JPL) coordinators have kept Mars time on and off at least since 1997 786309574Sglebiusfor the Mars Pathfinder mission. Some of their family members have 787309574Sglebiusalso adapted to Mars time. Dozens of special Mars watches were built 788309574Sglebiusfor JPL workers who kept Mars time during the Mars Exploration 789309574SglebiusRovers mission (2004). These timepieces look like normal Seikos and 790309574SglebiusCitizens but use Mars seconds rather than terrestrial seconds. 791309574Sglebius 792309574SglebiusA Mars solar day is called a "sol" and has a mean period equal to 793309574Sglebiusabout 24 hours 39 minutes 35.244 seconds in terrestrial time. It is 794309574Sglebiusdivided into a conventional 24-hour clock, so each Mars second equals 795309574Sglebiusabout 1.02749125 terrestrial seconds. 796309574Sglebius 797309574SglebiusThe prime meridian of Mars goes through the center of the crater 798309574SglebiusAiry-0, named in honor of the British astronomer who built the 799309574SglebiusGreenwich telescope that defines Earth's prime meridian. Mean solar 800309574Sglebiustime on the Mars prime meridian is called Mars Coordinated Time (MTC). 801309574Sglebius 802309574SglebiusEach landed mission on Mars has adopted a different reference for 803309574Sglebiussolar time keeping, so there is no real standard for Mars time zones. 804309574SglebiusFor example, the Mars Exploration Rover project (2004) defined two 805309574Sglebiustime zones "Local Solar Time A" and "Local Solar Time B" for its two 806309574Sglebiusmissions, each zone designed so that its time equals local true solar 807309574Sglebiustime at approximately the middle of the nominal mission. Such a "time 808309574Sglebiuszone" is not particularly suited for any application other than the 809309574Sglebiusmission itself. 810309574Sglebius 811309574SglebiusMany calendars have been proposed for Mars, but none have achieved 812309574Sglebiuswide acceptance. Astronomers often use Mars Sol Date (MSD) which is a 813309574Sglebiussequential count of Mars solar days elapsed since about 1873-12-29 814309574Sglebius12:00 GMT. 815309574Sglebius 816309574SglebiusThe tz database does not currently support Mars time, but it is 817309574Sglebiusdocumented here in the hopes that support will be added eventually. 818309574Sglebius 819309574SglebiusSources: 820309574Sglebius 821309574SglebiusMichael Allison and Robert Schmunk, 822309574Sglebius"Technical Notes on Mars Solar Time as Adopted by the Mars24 Sunclock" 823309574Sglebius<http://www.giss.nasa.gov/tools/mars24/help/notes.html> (2012-08-08). 824309574Sglebius 825309574SglebiusJia-Rui Chong, "Workdays Fit for a Martian", Los Angeles Times 826309574Sglebius<http://articles.latimes.com/2004/jan/14/science/sci-marstime14> 827309574Sglebius(2004-01-14), pp A1, A20-A21. 828309574Sglebius 829309574SglebiusTom Chmielewski, "Jet Lag Is Worse on Mars", The Atlantic (2015-02-26) 830309574Sglebius<http://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/> 831309574Sglebius 832309574Sglebius----- 833309574Sglebius 834309574SglebiusThis file is in the public domain, so clarified as of 2009-05-17 by 835309574SglebiusArthur David Olson. 836309574Sglebius 837309574Sglebius----- 838309574SglebiusLocal Variables: 839309574Sglebiuscoding: utf-8 840309574SglebiusEnd: 841