1309568SglebiusTheory and pragmatics of the tz code and data 2309568Sglebius 3309568Sglebius 4309568Sglebius----- Outline ----- 5309568Sglebius 6309568Sglebius Scope of the tz database 7309568Sglebius Names of time zone rules 8309568Sglebius Time zone abbreviations 9309568Sglebius Accuracy of the tz database 10309568Sglebius Time and date functions 11309568Sglebius Calendrical issues 12309568Sglebius Time and time zones on Mars 13309568Sglebius 14309568Sglebius 15309568Sglebius----- Scope of the tz database ----- 16309568Sglebius 17309568SglebiusThe tz database attempts to record the history and predicted future of 18309568Sglebiusall computer-based clocks that track civil time. To represent this 19309568Sglebiusdata, the world is partitioned into regions whose clocks all agree 20309568Sglebiusabout time stamps that occur after the somewhat-arbitrary cutoff point 21309568Sglebiusof the POSIX Epoch (1970-01-01 00:00:00 UTC). For each such region, 22309568Sglebiusthe database records all known clock transitions, and labels the region 23309568Sglebiuswith a notable location. Although 1970 is a somewhat-arbitrary 24309568Sglebiuscutoff, there are significant challenges to moving the cutoff earlier 25309568Sglebiuseven by a decade or two, due to the wide variety of local practices 26309568Sglebiusbefore computer timekeeping became prevalent. 27309568Sglebius 28309568SglebiusClock transitions before 1970 are recorded for each such location, 29309568Sglebiusbecause most systems support time stamps before 1970 and could 30309568Sglebiusmisbehave if data entries were omitted for pre-1970 transitions. 31309568SglebiusHowever, the database is not designed for and does not suffice for 32309568Sglebiusapplications requiring accurate handling of all past times everywhere, 33309568Sglebiusas it would take far too much effort and guesswork to record all 34309568Sglebiusdetails of pre-1970 civil timekeeping. 35309568Sglebius 36309568SglebiusAs described below, reference source code for using the tz database is 37309568Sglebiusalso available. The tz code is upwards compatible with POSIX, an 38309568Sglebiusinternational standard for UNIX-like systems. As of this writing, the 39309568Sglebiuscurrent edition of POSIX is: 40309568Sglebius 41309568Sglebius The Open Group Base Specifications Issue 7 42309568Sglebius IEEE Std 1003.1, 2013 Edition 43309568Sglebius <http://pubs.opengroup.org/onlinepubs/9699919799/> 44309568Sglebius 45309568Sglebius 46309568Sglebius 47309568Sglebius----- Names of time zone rules ----- 48309568Sglebius 49309568SglebiusEach of the database's time zone rules has a unique name. 50309568SglebiusInexperienced users are not expected to select these names unaided. 51309568SglebiusDistributors should provide documentation and/or a simple selection 52309568Sglebiusinterface that explains the names; for one example, see the 'tzselect' 53309568Sglebiusprogram in the tz code. The Unicode Common Locale Data Repository 54309568Sglebius<http://cldr.unicode.org/> contains data that may be useful for other 55309568Sglebiusselection interfaces. 56309568Sglebius 57309568SglebiusThe time zone rule naming conventions attempt to strike a balance 58309568Sglebiusamong the following goals: 59309568Sglebius 60309568Sglebius * Uniquely identify every region where clocks have agreed since 1970. 61309568Sglebius This is essential for the intended use: static clocks keeping local 62309568Sglebius civil time. 63309568Sglebius 64309568Sglebius * Indicate to experts where that region is. 65309568Sglebius 66309568Sglebius * Be robust in the presence of political changes. For example, names 67309568Sglebius of countries are ordinarily not used, to avoid incompatibilities 68309568Sglebius when countries change their name (e.g. Zaire->Congo) or when 69309568Sglebius locations change countries (e.g. Hong Kong from UK colony to 70309568Sglebius China). 71309568Sglebius 72309568Sglebius * Be portable to a wide variety of implementations. 73309568Sglebius 74309568Sglebius * Use a consistent naming conventions over the entire world. 75309568Sglebius 76309568SglebiusNames normally have the form AREA/LOCATION, where AREA is the name 77309568Sglebiusof a continent or ocean, and LOCATION is the name of a specific 78309568Sglebiuslocation within that region. North and South America share the same 79309568Sglebiusarea, 'America'. Typical names are 'Africa/Cairo', 'America/New_York', 80309568Sglebiusand 'Pacific/Honolulu'. 81309568Sglebius 82309568SglebiusHere are the general rules used for choosing location names, 83309568Sglebiusin decreasing order of importance: 84309568Sglebius 85309568Sglebius Use only valid POSIX file name components (i.e., the parts of 86309568Sglebius names other than '/'). Do not use the file name 87309568Sglebius components '.' and '..'. Within a file name component, 88309568Sglebius use only ASCII letters, '.', '-' and '_'. Do not use 89309568Sglebius digits, as that might create an ambiguity with POSIX 90309568Sglebius TZ strings. A file name component must not exceed 14 91309568Sglebius characters or start with '-'. E.g., prefer 'Brunei' 92309568Sglebius to 'Bandar_Seri_Begawan'. Exceptions: see the discussion 93309568Sglebius of legacy names below. 94309568Sglebius A name must not be empty, or contain '//', or start or end with '/'. 95309568Sglebius Do not use names that differ only in case. Although the reference 96309568Sglebius implementation is case-sensitive, some other implementations 97309568Sglebius are not, and they would mishandle names differing only in case. 98309568Sglebius If one name A is an initial prefix of another name AB (ignoring case), 99309568Sglebius then B must not start with '/', as a regular file cannot have 100309568Sglebius the same name as a directory in POSIX. For example, 101309568Sglebius 'America/New_York' precludes 'America/New_York/Bronx'. 102309568Sglebius Uninhabited regions like the North Pole and Bouvet Island 103309568Sglebius do not need locations, since local time is not defined there. 104309568Sglebius There should typically be at least one name for each ISO 3166-1 105309568Sglebius officially assigned two-letter code for an inhabited country 106309568Sglebius or territory. 107309568Sglebius If all the clocks in a region have agreed since 1970, 108309568Sglebius don't bother to include more than one location 109309568Sglebius even if subregions' clocks disagreed before 1970. 110309568Sglebius Otherwise these tables would become annoyingly large. 111309568Sglebius If a name is ambiguous, use a less ambiguous alternative; 112309568Sglebius e.g. many cities are named San Jos�� and Georgetown, so 113309568Sglebius prefer 'Costa_Rica' to 'San_Jose' and 'Guyana' to 'Georgetown'. 114309568Sglebius Keep locations compact. Use cities or small islands, not countries 115309568Sglebius or regions, so that any future time zone changes do not split 116309568Sglebius locations into different time zones. E.g. prefer 'Paris' 117309568Sglebius to 'France', since France has had multiple time zones. 118309568Sglebius Use mainstream English spelling, e.g. prefer 'Rome' to 'Roma', and 119309568Sglebius prefer 'Athens' to the Greek '����������' or the Romanized 'Ath��na'. 120309568Sglebius The POSIX file name restrictions encourage this rule. 121309568Sglebius Use the most populous among locations in a zone, 122309568Sglebius e.g. prefer 'Shanghai' to 'Beijing'. Among locations with 123309568Sglebius similar populations, pick the best-known location, 124309568Sglebius e.g. prefer 'Rome' to 'Milan'. 125309568Sglebius Use the singular form, e.g. prefer 'Canary' to 'Canaries'. 126309568Sglebius Omit common suffixes like '_Islands' and '_City', unless that 127309568Sglebius would lead to ambiguity. E.g. prefer 'Cayman' to 128309568Sglebius 'Cayman_Islands' and 'Guatemala' to 'Guatemala_City', 129309568Sglebius but prefer 'Mexico_City' to 'Mexico' because the country 130309568Sglebius of Mexico has several time zones. 131309568Sglebius Use '_' to represent a space. 132309568Sglebius Omit '.' from abbreviations in names, e.g. prefer 'St_Helena' 133309568Sglebius to 'St._Helena'. 134309568Sglebius Do not change established names if they only marginally 135309568Sglebius violate the above rules. For example, don't change 136309568Sglebius the existing name 'Rome' to 'Milan' merely because 137309568Sglebius Milan's population has grown to be somewhat greater 138309568Sglebius than Rome's. 139309568Sglebius If a name is changed, put its old spelling in the 'backward' file. 140309568Sglebius This means old spellings will continue to work. 141309568Sglebius 142309568SglebiusThe file 'zone1970.tab' lists geographical locations used to name time 143309568Sglebiuszone rules. It is intended to be an exhaustive list of names for 144309568Sglebiusgeographic regions as described above; this is a subset of the names 145309568Sglebiusin the data. Although a 'zone1970.tab' location's longitude 146309568Sglebiuscorresponds to its LMT offset with one hour for every 15 degrees east 147309568Sglebiuslongitude, this relationship is not exact. 148309568Sglebius 149309568SglebiusOlder versions of this package used a different naming scheme, 150309568Sglebiusand these older names are still supported. 151309568SglebiusSee the file 'backward' for most of these older names 152309568Sglebius(e.g., 'US/Eastern' instead of 'America/New_York'). 153309568SglebiusThe other old-fashioned names still supported are 154309568Sglebius'WET', 'CET', 'MET', and 'EET' (see the file 'europe'). 155309568Sglebius 156309568SglebiusOlder versions of this package defined legacy names that are 157309568Sglebiusincompatible with the first rule of location names, but which are 158309568Sglebiusstill supported. These legacy names are mostly defined in the file 159309568Sglebius'etcetera'. Also, the file 'backward' defines the legacy names 160309568Sglebius'GMT0', 'GMT-0', 'GMT+0' and 'Canada/East-Saskatchewan', and the file 161309568Sglebius'northamerica' defines the legacy names 'EST5EDT', 'CST6CDT', 162309568Sglebius'MST7MDT', and 'PST8PDT'. 163309568Sglebius 164309568SglebiusExcluding 'backward' should not affect the other data. If 165309568Sglebius'backward' is excluded, excluding 'etcetera' should not affect the 166309568Sglebiusremaining data. 167309568Sglebius 168309568Sglebius 169309568Sglebius----- Time zone abbreviations ----- 170309568Sglebius 171309568SglebiusWhen this package is installed, it generates time zone abbreviations 172309568Sglebiuslike 'EST' to be compatible with human tradition and POSIX. 173309568SglebiusHere are the general rules used for choosing time zone abbreviations, 174309568Sglebiusin decreasing order of importance: 175309568Sglebius 176309568Sglebius Use three or more characters that are ASCII alphanumerics or '+' or '-'. 177309568Sglebius Previous editions of this database also used characters like 178309568Sglebius ' ' and '?', but these characters have a special meaning to 179309568Sglebius the shell and cause commands like 180309568Sglebius set `date` 181309568Sglebius to have unexpected effects. 182309568Sglebius Previous editions of this rule required upper-case letters, 183309568Sglebius but the Congressman who introduced Chamorro Standard Time 184309568Sglebius preferred "ChST", so lower-case letters are now allowed. 185309568Sglebius Also, POSIX from 2001 on relaxed the rule to allow '-', '+', 186309568Sglebius and alphanumeric characters from the portable character set 187309568Sglebius in the current locale. In practice ASCII alphanumerics and 188309568Sglebius '+' and '-' are safe in all locales. 189309568Sglebius 190309568Sglebius In other words, in the C locale the POSIX extended regular 191309568Sglebius expression [-+[:alnum:]]{3,} should match the abbreviation. 192309568Sglebius This guarantees that all abbreviations could have been 193309568Sglebius specified by a POSIX TZ string. 194309568Sglebius 195309568Sglebius Use abbreviations that are in common use among English-speakers, 196309568Sglebius e.g. 'EST' for Eastern Standard Time in North America. 197309568Sglebius We assume that applications translate them to other languages 198309568Sglebius as part of the normal localization process; for example, 199309568Sglebius a French application might translate 'EST' to 'HNE'. 200309568Sglebius 201309568Sglebius For zones whose times are taken from a city's longitude, use the 202309568Sglebius traditional xMT notation, e.g. 'PMT' for Paris Mean Time. 203309568Sglebius The only name like this in current use is 'GMT'. 204309568Sglebius 205309568Sglebius Use 'LMT' for local mean time of locations before the introduction 206309568Sglebius of standard time; see "Scope of the tz database". 207309568Sglebius 208309568Sglebius If there is no common English abbreviation, use numeric offsets like 209309568Sglebius -05 and +0830 that are generated by zic's %z notation. 210309568Sglebius 211309568Sglebius [The remaining guidelines predate the introduction of %z. 212309568Sglebius They are problematic as they mean tz data entries invent 213309568Sglebius notation rather than record it. These guidelines are now 214309568Sglebius deprecated and the plan is to gradually move to %z for 215309568Sglebius inhabited locations and to "-00" for uninhabited locations.] 216309568Sglebius 217309568Sglebius If there is no common English abbreviation, abbreviate the English 218309568Sglebius translation of the usual phrase used by native speakers. 219309568Sglebius If this is not available or is a phrase mentioning the country 220309568Sglebius (e.g. "Cape Verde Time"), then: 221309568Sglebius 222309568Sglebius When a country is identified with a single or principal zone, 223309568Sglebius append 'T' to the country's ISO code, e.g. 'CVT' for 224309568Sglebius Cape Verde Time. For summer time append 'ST'; 225309568Sglebius for double summer time append 'DST'; etc. 226309568Sglebius Otherwise, take the first three letters of an English place 227309568Sglebius name identifying each zone and append 'T', 'ST', etc. 228309568Sglebius as before; e.g. 'VLAST' for VLAdivostok Summer Time. 229309568Sglebius 230309568Sglebius Use UT (with time zone abbreviation '-00') for locations while 231309568Sglebius uninhabited. The leading '-' is a flag that the time 232309568Sglebius zone is in some sense undefined; this notation is 233309568Sglebius derived from Internet RFC 3339. 234309568Sglebius 235309568SglebiusApplication writers should note that these abbreviations are ambiguous 236309568Sglebiusin practice: e.g. 'CST' has a different meaning in China than 237309568Sglebiusit does in the United States. In new applications, it's often better 238309568Sglebiusto use numeric UT offsets like '-0600' instead of time zone 239309568Sglebiusabbreviations like 'CST'; this avoids the ambiguity. 240309568Sglebius 241309568Sglebius 242309568Sglebius----- Accuracy of the tz database ----- 243309568Sglebius 244309568SglebiusThe tz database is not authoritative, and it surely has errors. 245309568SglebiusCorrections are welcome and encouraged; see the file CONTRIBUTING. 246309568SglebiusUsers requiring authoritative data should consult national standards 247309568Sglebiusbodies and the references cited in the database's comments. 248309568Sglebius 249309568SglebiusErrors in the tz database arise from many sources: 250309568Sglebius 251309568Sglebius * The tz database predicts future time stamps, and current predictions 252309568Sglebius will be incorrect after future governments change the rules. 253309568Sglebius For example, if today someone schedules a meeting for 13:00 next 254309568Sglebius October 1, Casablanca time, and tomorrow Morocco changes its 255309568Sglebius daylight saving rules, software can mess up after the rule change 256309568Sglebius if it blithely relies on conversions made before the change. 257309568Sglebius 258309568Sglebius * The pre-1970 entries in this database cover only a tiny sliver of how 259309568Sglebius clocks actually behaved; the vast majority of the necessary 260309568Sglebius information was lost or never recorded. Thousands more zones would 261309568Sglebius be needed if the tz database's scope were extended to cover even 262309568Sglebius just the known or guessed history of standard time; for example, 263309568Sglebius the current single entry for France would need to split into dozens 264309568Sglebius of entries, perhaps hundreds. And in most of the world even this 265309568Sglebius approach would be misleading due to widespread disagreement or 266309568Sglebius indifference about what times should be observed. In her 2015 book 267309568Sglebius "The Global Transformation of Time, 1870-1950", Vanessa Ogle writes 268309568Sglebius "Outside of Europe and North America there was no system of time 269309568Sglebius zones at all, often not even a stable landscape of mean times, 270309568Sglebius prior to the middle decades of the twentieth century". See: 271309568Sglebius Timothy Shenk, Booked: A Global History of Time. Dissent 2015-12-17 272309568Sglebius https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle 273309568Sglebius 274309568Sglebius * Most of the pre-1970 data entries come from unreliable sources, often 275309568Sglebius astrology books that lack citations and whose compilers evidently 276309568Sglebius invented entries when the true facts were unknown, without 277309568Sglebius reporting which entries were known and which were invented. 278309568Sglebius These books often contradict each other or give implausible entries, 279309568Sglebius and on the rare occasions when they are checked they are 280309568Sglebius typically found to be incorrect. 281309568Sglebius 282309568Sglebius * For the UK the tz database relies on years of first-class work done by 283309568Sglebius Joseph Myers and others; see <http://www.polyomino.org.uk/british-time/>. 284309568Sglebius Other countries are not done nearly as well. 285309568Sglebius 286309568Sglebius * Sometimes, different people in the same city would maintain clocks 287309568Sglebius that differed significantly. Railway time was used by railroad 288309568Sglebius companies (which did not always agree with each other), 289309568Sglebius church-clock time was used for birth certificates, etc. 290309568Sglebius Often this was merely common practice, but sometimes it was set by law. 291309568Sglebius For example, from 1891 to 1911 the UT offset in France was legally 292309568Sglebius 0:09:21 outside train stations and 0:04:21 inside. 293309568Sglebius 294309568Sglebius * Although a named location in the tz database stands for the 295309568Sglebius containing region, its pre-1970 data entries are often accurate for 296309568Sglebius only a small subset of that region. For example, Europe/London 297309568Sglebius stands for the United Kingdom, but its pre-1847 times are valid 298309568Sglebius only for locations that have London's exact meridian, and its 1847 299309568Sglebius transition to GMT is known to be valid only for the L&NW and the 300309568Sglebius Caledonian railways. 301309568Sglebius 302309568Sglebius * The tz database does not record the earliest time for which a zone's 303309568Sglebius data entries are thereafter valid for every location in the region. 304309568Sglebius For example, Europe/London is valid for all locations in its 305309568Sglebius region after GMT was made the standard time, but the date of 306309568Sglebius standardization (1880-08-02) is not in the tz database, other than 307309568Sglebius in commentary. For many zones the earliest time of validity is 308309568Sglebius unknown. 309309568Sglebius 310309568Sglebius * The tz database does not record a region's boundaries, and in many 311309568Sglebius cases the boundaries are not known. For example, the zone 312309568Sglebius America/Kentucky/Louisville represents a region around the city of 313309568Sglebius Louisville, the boundaries of which are unclear. 314309568Sglebius 315309568Sglebius * Changes that are modeled as instantaneous transitions in the tz 316309568Sglebius database were often spread out over hours, days, or even decades. 317309568Sglebius 318309568Sglebius * Even if the time is specified by law, locations sometimes 319309568Sglebius deliberately flout the law. 320309568Sglebius 321309568Sglebius * Early timekeeping practices, even assuming perfect clocks, were 322309568Sglebius often not specified to the accuracy that the tz database requires. 323309568Sglebius 324309568Sglebius * Sometimes historical timekeeping was specified more precisely 325309568Sglebius than what the tz database can handle. For example, from 1909 to 326309568Sglebius 1937 Netherlands clocks were legally UT +00:19:32.13, but the tz 327309568Sglebius database cannot represent the fractional second. 328309568Sglebius 329309568Sglebius * Even when all the timestamp transitions recorded by the tz database 330309568Sglebius are correct, the tz rules that generate them may not faithfully 331309568Sglebius reflect the historical rules. For example, from 1922 until World 332309568Sglebius War II the UK moved clocks forward the day following the third 333309568Sglebius Saturday in April unless that was Easter, in which case it moved 334309568Sglebius clocks forward the previous Sunday. Because the tz database has no 335309568Sglebius way to specify Easter, these exceptional years are entered as 336309568Sglebius separate tz Rule lines, even though the legal rules did not change. 337309568Sglebius 338309568Sglebius * The tz database models pre-standard time using the proleptic Gregorian 339309568Sglebius calendar and local mean time (LMT), but many people used other 340309568Sglebius calendars and other timescales. For example, the Roman Empire used 341309568Sglebius the Julian calendar, and had 12 varying-length daytime hours with a 342309568Sglebius non-hour-based system at night. 343309568Sglebius 344309568Sglebius * Early clocks were less reliable, and data entries do not represent 345309568Sglebius this unreliability. 346309568Sglebius 347309568Sglebius * As for leap seconds, civil time was not based on atomic time before 348309568Sglebius 1972, and we don't know the history of earth's rotation accurately 349309568Sglebius enough to map SI seconds to historical solar time to more than 350309568Sglebius about one-hour accuracy. See: Morrison LV, Stephenson FR. 351309568Sglebius Historical values of the Earth's clock error Delta T and the 352309568Sglebius calculation of eclipses. J Hist Astron. 2004;35:327-36 353309568Sglebius <http://adsabs.harvard.edu/full/2004JHA....35..327M>; 354309568Sglebius Historical values of the Earth's clock error. J Hist Astron. 2005;36:339 355309568Sglebius <http://adsabs.harvard.edu/full/2005JHA....36..339M>. 356309568Sglebius 357309568Sglebius * The relationship between POSIX time (that is, UTC but ignoring leap 358309568Sglebius seconds) and UTC is not agreed upon after 1972. Although the POSIX 359309568Sglebius clock officially stops during an inserted leap second, at least one 360309568Sglebius proposed standard has it jumping back a second instead; and in 361309568Sglebius practice POSIX clocks more typically either progress glacially during 362309568Sglebius a leap second, or are slightly slowed while near a leap second. 363309568Sglebius 364309568Sglebius * The tz database does not represent how uncertain its information is. 365309568Sglebius Ideally it would contain information about when data entries are 366309568Sglebius incomplete or dicey. Partial temporal knowledge is a field of 367309568Sglebius active research, though, and it's not clear how to apply it here. 368309568Sglebius 369309568SglebiusIn short, many, perhaps most, of the tz database's pre-1970 and future 370309568Sglebiustime stamps are either wrong or misleading. Any attempt to pass the 371309568Sglebiustz database off as the definition of time should be unacceptable to 372309568Sglebiusanybody who cares about the facts. In particular, the tz database's 373309568SglebiusLMT offsets should not be considered meaningful, and should not prompt 374309568Sglebiuscreation of zones merely because two locations differ in LMT or 375309568Sglebiustransitioned to standard time at different dates. 376309568Sglebius 377309568Sglebius 378309568Sglebius----- Time and date functions ----- 379309568Sglebius 380309568SglebiusThe tz code contains time and date functions that are upwards 381309568Sglebiuscompatible with those of POSIX. 382309568Sglebius 383309568SglebiusPOSIX has the following properties and limitations. 384309568Sglebius 385309568Sglebius* In POSIX, time display in a process is controlled by the 386309568Sglebius environment variable TZ. Unfortunately, the POSIX TZ string takes 387309568Sglebius a form that is hard to describe and is error-prone in practice. 388309568Sglebius Also, POSIX TZ strings can't deal with other (for example, Israeli) 389309568Sglebius daylight saving time rules, or situations where more than two 390309568Sglebius time zone abbreviations are used in an area. 391309568Sglebius 392309568Sglebius The POSIX TZ string takes the following form: 393309568Sglebius 394309568Sglebius stdoffset[dst[offset][,date[/time],date[/time]]] 395309568Sglebius 396309568Sglebius where: 397309568Sglebius 398309568Sglebius std and dst 399309568Sglebius are 3 or more characters specifying the standard 400309568Sglebius and daylight saving time (DST) zone names. 401309568Sglebius Starting with POSIX.1-2001, std and dst may also be 402309568Sglebius in a quoted form like "<UTC+10>"; this allows 403309568Sglebius "+" and "-" in the names. 404309568Sglebius offset 405309568Sglebius is of the form '[+-]hh:[mm[:ss]]' and specifies the 406309568Sglebius offset west of UT. 'hh' may be a single digit; 0<=hh<=24. 407309568Sglebius The default DST offset is one hour ahead of standard time. 408309568Sglebius date[/time],date[/time] 409309568Sglebius specifies the beginning and end of DST. If this is absent, 410309568Sglebius the system supplies its own rules for DST, and these can 411309568Sglebius differ from year to year; typically US DST rules are used. 412309568Sglebius time 413309568Sglebius takes the form 'hh:[mm[:ss]]' and defaults to 02:00. 414309568Sglebius This is the same format as the offset, except that a 415309568Sglebius leading '+' or '-' is not allowed. 416309568Sglebius date 417309568Sglebius takes one of the following forms: 418309568Sglebius Jn (1<=n<=365) 419309568Sglebius origin-1 day number not counting February 29 420309568Sglebius n (0<=n<=365) 421309568Sglebius origin-0 day number counting February 29 if present 422309568Sglebius Mm.n.d (0[Sunday]<=d<=6[Saturday], 1<=n<=5, 1<=m<=12) 423309568Sglebius for the dth day of week n of month m of the year, 424309568Sglebius where week 1 is the first week in which day d appears, 425309568Sglebius and '5' stands for the last week in which day d appears 426309568Sglebius (which may be either the 4th or 5th week). 427309568Sglebius Typically, this is the only useful form; 428309568Sglebius the n and Jn forms are rarely used. 429309568Sglebius 430309568Sglebius Here is an example POSIX TZ string, for US Pacific time using rules 431309568Sglebius appropriate from 1987 through 2006: 432309568Sglebius 433309568Sglebius TZ='PST8PDT,M4.1.0/02:00,M10.5.0/02:00' 434309568Sglebius 435309568Sglebius This POSIX TZ string is hard to remember, and mishandles time stamps 436309568Sglebius before 1987 and after 2006. With this package you can use this 437309568Sglebius instead: 438309568Sglebius 439309568Sglebius TZ='America/Los_Angeles' 440309568Sglebius 441309568Sglebius* POSIX does not define the exact meaning of TZ values like "EST5EDT". 442309568Sglebius Typically the current US DST rules are used to interpret such values, 443309568Sglebius but this means that the US DST rules are compiled into each program 444309568Sglebius that does time conversion. This means that when US time conversion 445309568Sglebius rules change (as in the United States in 1987), all programs that 446309568Sglebius do time conversion must be recompiled to ensure proper results. 447309568Sglebius 448309568Sglebius* The TZ environment variable is process-global, which makes it hard 449309568Sglebius to write efficient, thread-safe applications that need access 450309568Sglebius to multiple time zones. 451309568Sglebius 452309568Sglebius* In POSIX, there's no tamper-proof way for a process to learn the 453309568Sglebius system's best idea of local wall clock. (This is important for 454309568Sglebius applications that an administrator wants used only at certain times - 455309568Sglebius without regard to whether the user has fiddled the "TZ" environment 456309568Sglebius variable. While an administrator can "do everything in UTC" to get 457309568Sglebius around the problem, doing so is inconvenient and precludes handling 458309568Sglebius daylight saving time shifts - as might be required to limit phone 459309568Sglebius calls to off-peak hours.) 460309568Sglebius 461309568Sglebius* POSIX provides no convenient and efficient way to determine the UT 462309568Sglebius offset and time zone abbreviation of arbitrary time stamps, 463309568Sglebius particularly for time zone settings that do not fit into the 464309568Sglebius POSIX model. 465309568Sglebius 466309568Sglebius* POSIX requires that systems ignore leap seconds. 467309568Sglebius 468309568Sglebius* The tz code attempts to support all the time_t implementations 469309568Sglebius allowed by POSIX. The time_t type represents a nonnegative count of 470309568Sglebius seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds. 471309568Sglebius In practice, time_t is usually a signed 64- or 32-bit integer; 32-bit 472309568Sglebius signed time_t values stop working after 2038-01-19 03:14:07 UTC, so 473309568Sglebius new implementations these days typically use a signed 64-bit integer. 474309568Sglebius Unsigned 32-bit integers are used on one or two platforms, 475309568Sglebius and 36-bit and 40-bit integers are also used occasionally. 476309568Sglebius Although earlier POSIX versions allowed time_t to be a 477309568Sglebius floating-point type, this was not supported by any practical 478309568Sglebius systems, and POSIX.1-2013 and the tz code both require time_t 479309568Sglebius to be an integer type. 480309568Sglebius 481309568SglebiusThese are the extensions that have been made to the POSIX functions: 482309568Sglebius 483309568Sglebius* The "TZ" environment variable is used in generating the name of a file 484309568Sglebius from which time zone information is read (or is interpreted a la 485309568Sglebius POSIX); "TZ" is no longer constrained to be a three-letter time zone 486309568Sglebius name followed by a number of hours and an optional three-letter 487309568Sglebius daylight time zone name. The daylight saving time rules to be used 488309568Sglebius for a particular time zone are encoded in the time zone file; 489309568Sglebius the format of the file allows U.S., Australian, and other rules to be 490309568Sglebius encoded, and allows for situations where more than two time zone 491309568Sglebius abbreviations are used. 492309568Sglebius 493309568Sglebius It was recognized that allowing the "TZ" environment variable to 494309568Sglebius take on values such as "America/New_York" might cause "old" programs 495309568Sglebius (that expect "TZ" to have a certain form) to operate incorrectly; 496309568Sglebius consideration was given to using some other environment variable 497309568Sglebius (for example, "TIMEZONE") to hold the string used to generate the 498309568Sglebius time zone information file name. In the end, however, it was decided 499309568Sglebius to continue using "TZ": it is widely used for time zone purposes; 500309568Sglebius separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance; 501309568Sglebius and systems where "new" forms of "TZ" might cause problems can simply 502309568Sglebius use TZ values such as "EST5EDT" which can be used both by 503309568Sglebius "new" programs (a la POSIX) and "old" programs (as zone names and 504309568Sglebius offsets). 505309568Sglebius 506309568Sglebius* The code supports platforms with a UT offset member in struct tm, 507309568Sglebius e.g., tm_gmtoff. 508309568Sglebius 509309568Sglebius* The code supports platforms with a time zone abbreviation member in 510309568Sglebius struct tm, e.g., tm_zone. 511309568Sglebius 512309568Sglebius* Since the "TZ" environment variable can now be used to control time 513309568Sglebius conversion, the "daylight" and "timezone" variables are no longer 514309568Sglebius needed. (These variables are defined and set by "tzset"; however, their 515309568Sglebius values will not be used by "localtime.") 516309568Sglebius 517309568Sglebius* Functions tzalloc, tzfree, localtime_rz, and mktime_z for 518309568Sglebius more-efficient thread-safe applications that need to use 519309568Sglebius multiple time zones. The tzalloc and tzfree functions 520309568Sglebius allocate and free objects of type timezone_t, and localtime_rz 521309568Sglebius and mktime_z are like localtime_r and mktime with an extra 522309568Sglebius timezone_t argument. The functions were inspired by NetBSD. 523309568Sglebius 524309568Sglebius* A function "tzsetwall" has been added to arrange for the system's 525309568Sglebius best approximation to local wall clock time to be delivered by 526309568Sglebius subsequent calls to "localtime." Source code for portable 527309568Sglebius applications that "must" run on local wall clock time should call 528309568Sglebius "tzsetwall();" if such code is moved to "old" systems that don't 529309568Sglebius provide tzsetwall, you won't be able to generate an executable program. 530309568Sglebius (These time zone functions also arrange for local wall clock time to be 531309568Sglebius used if tzset is called - directly or indirectly - and there's no "TZ" 532309568Sglebius environment variable; portable applications should not, however, rely 533309568Sglebius on this behavior since it's not the way SVR2 systems behave.) 534309568Sglebius 535309568Sglebius* Negative time_t values are supported, on systems where time_t is signed. 536309568Sglebius 537309568Sglebius* These functions can account for leap seconds, thanks to Bradley White. 538309568Sglebius 539309568SglebiusPoints of interest to folks with other systems: 540309568Sglebius 541309568Sglebius* Code compatible with this package is already part of many platforms, 542309568Sglebius including GNU/Linux, Android, the BSDs, Chromium OS, Cygwin, AIX, iOS, 543309568Sglebius BlackBery 10, macOS, Microsoft Windows, OpenVMS, and Solaris. 544309568Sglebius On such hosts, the primary use of this package 545309568Sglebius is to update obsolete time zone rule tables. 546309568Sglebius To do this, you may need to compile the time zone compiler 547309568Sglebius 'zic' supplied with this package instead of using the system 'zic', 548309568Sglebius since the format of zic's input is occasionally extended, 549309568Sglebius and a platform may still be shipping an older zic. 550309568Sglebius 551309568Sglebius* The UNIX Version 7 "timezone" function is not present in this package; 552309568Sglebius it's impossible to reliably map timezone's arguments (a "minutes west 553309568Sglebius of GMT" value and a "daylight saving time in effect" flag) to a 554309568Sglebius time zone abbreviation, and we refuse to guess. 555309568Sglebius Programs that in the past used the timezone function may now examine 556309568Sglebius tzname[localtime(&clock)->tm_isdst] to learn the correct time 557309568Sglebius zone abbreviation to use. Alternatively, use 558309568Sglebius localtime(&clock)->tm_zone if this has been enabled. 559309568Sglebius 560309568Sglebius* The 4.2BSD gettimeofday function is not used in this package. 561309568Sglebius This formerly let users obtain the current UTC offset and DST flag, 562309568Sglebius but this functionality was removed in later versions of BSD. 563309568Sglebius 564309568Sglebius* In SVR2, time conversion fails for near-minimum or near-maximum 565309568Sglebius time_t values when doing conversions for places that don't use UT. 566309568Sglebius This package takes care to do these conversions correctly. 567309568Sglebius A comment in the source code tells how to get compatibly wrong 568309568Sglebius results. 569309568Sglebius 570309568SglebiusThe functions that are conditionally compiled if STD_INSPIRED is defined 571309568Sglebiusshould, at this point, be looked on primarily as food for thought. They are 572309568Sglebiusnot in any sense "standard compatible" - some are not, in fact, specified in 573309568Sglebius*any* standard. They do, however, represent responses of various authors to 574309568Sglebiusstandardization proposals. 575309568Sglebius 576309568SglebiusOther time conversion proposals, in particular the one developed by folks at 577309568SglebiusHewlett Packard, offer a wider selection of functions that provide capabilities 578309568Sglebiusbeyond those provided here. The absence of such functions from this package 579309568Sglebiusis not meant to discourage the development, standardization, or use of such 580309568Sglebiusfunctions. Rather, their absence reflects the decision to make this package 581309568Sglebiuscontain valid extensions to POSIX, to ensure its broad acceptability. If 582309568Sglebiusmore powerful time conversion functions can be standardized, so much the 583309568Sglebiusbetter. 584309568Sglebius 585309568Sglebius 586309568Sglebius----- Interface stability ----- 587309568Sglebius 588309568SglebiusThe tz code and data supply the following interfaces: 589309568Sglebius 590309568Sglebius * A set of zone names as per "Names of time zone rules" above. 591309568Sglebius 592309568Sglebius * Library functions described in "Time and date functions" above. 593309568Sglebius 594309568Sglebius * The programs tzselect, zdump, and zic, documented in their man pages. 595309568Sglebius 596309568Sglebius * The format of zic input files, documented in the zic man page. 597309568Sglebius 598309568Sglebius * The format of zic output files, documented in the tzfile man page. 599309568Sglebius 600309568Sglebius * The format of zone table files, documented in zone1970.tab. 601309568Sglebius 602309568Sglebius * The format of the country code file, documented in iso3166.tab. 603309568Sglebius 604309568SglebiusWhen these interfaces are changed, an effort is made to preserve 605309568Sglebiusbackward compatibility. For example, tz data files typically do not 606309568Sglebiusrely on recently-added zic features, so that users can run older zic 607309568Sglebiusversions to process newer data files. 608309568Sglebius 609309568SglebiusInterfaces not listed above are less stable. For example, users 610309568Sglebiusshould not rely on particular UT offsets or abbreviations for time 611309568Sglebiusstamps, as data entries are often based on guesswork and these guesses 612309568Sglebiusmay be corrected or improved. 613309568Sglebius 614309568Sglebius 615309568Sglebius----- Calendrical issues ----- 616309568Sglebius 617309568SglebiusCalendrical issues are a bit out of scope for a time zone database, 618309568Sglebiusbut they indicate the sort of problems that we would run into if we 619309568Sglebiusextended the time zone database further into the past. An excellent 620309568Sglebiusresource in this area is Nachum Dershowitz and Edward M. Reingold, 621309568SglebiusCalendrical Calculations: Third Edition, Cambridge University Press (2008) 622309568Sglebius<http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/>. 623309568SglebiusOther information and sources are given below. They sometimes disagree. 624309568Sglebius 625309568Sglebius 626309568SglebiusFrance 627309568Sglebius 628309568SglebiusGregorian calendar adopted 1582-12-20. 629309568SglebiusFrench Revolutionary calendar used 1793-11-24 through 1805-12-31, 630309568Sglebiusand (in Paris only) 1871-05-06 through 1871-05-23. 631309568Sglebius 632309568Sglebius 633309568SglebiusRussia 634309568Sglebius 635309568SglebiusFrom Chris Carrier (1996-12-02): 636309568SglebiusOn 1929-10-01 the Soviet Union instituted an "Eternal Calendar" 637309568Sglebiuswith 30-day months plus 5 holidays, with a 5-day week. 638309568SglebiusOn 1931-12-01 it changed to a 6-day week; in 1934 it reverted to the 639309568SglebiusGregorian calendar while retaining the 6-day week; on 1940-06-27 it 640309568Sglebiusreverted to the 7-day week. With the 6-day week the usual days 641309568Sglebiusoff were the 6th, 12th, 18th, 24th and 30th of the month. 642309568Sglebius(Source: Evitiar Zerubavel, _The Seven Day Circle_) 643309568Sglebius 644309568Sglebius 645309568SglebiusMark Brader reported a similar story in "The Book of Calendars", edited 646309568Sglebiusby Frank Parise (1982, Facts on File, ISBN 0-8719-6467-8), page 377. But: 647309568Sglebius 648309568SglebiusFrom: Petteri Sulonen (via Usenet) 649309568SglebiusDate: 14 Jan 1999 00:00:00 GMT 650309568Sglebius... 651309568Sglebius 652309568SglebiusIf your source is correct, how come documents between 1929 and 1940 were 653309568Sglebiusstill dated using the conventional, Gregorian calendar? 654309568Sglebius 655309568SglebiusI can post a scan of a document dated December 1, 1934, signed by 656309568SglebiusYenukidze, the secretary, on behalf of Kalinin, the President of the 657309568SglebiusExecutive Committee of the Supreme Soviet, if you like. 658309568Sglebius 659309568Sglebius 660309568Sglebius 661309568SglebiusSweden (and Finland) 662309568Sglebius 663309568SglebiusFrom: Mark Brader 664309568SglebiusSubject: Re: Gregorian reform - a part of locale? 665309568Sglebius<news:1996Jul6.012937.29190@sq.com> 666309568SglebiusDate: 1996-07-06 667309568Sglebius 668309568SglebiusIn 1700, Denmark made the transition from Julian to Gregorian. Sweden 669309568Sglebiusdecided to *start* a transition in 1700 as well, but rather than have one of 670309568Sglebiusthose unsightly calendar gaps :-), they simply decreed that the next leap 671309568Sglebiusyear after 1696 would be in 1744 - putting the whole country on a calendar 672309568Sglebiusdifferent from both Julian and Gregorian for a period of 40 years. 673309568Sglebius 674309568SglebiusHowever, in 1704 something went wrong and the plan was not carried through; 675309568Sglebiusthey did, after all, have a leap year that year. And one in 1708. In 1712 676309568Sglebiusthey gave it up and went back to Julian, putting 30 days in February that 677309568Sglebiusyear!... 678309568Sglebius 679309568SglebiusThen in 1753, Sweden made the transition to Gregorian in the usual manner, 680309568Sglebiusgetting there only 13 years behind the original schedule. 681309568Sglebius 682309568Sglebius(A previous posting of this story was challenged, and Swedish readers 683309568Sglebiusproduced the following references to support it: "Tider��kning och historia" 684309568Sglebiusby Natanael Beckman (1924) and "Tid, en bok om tider��kning och 685309568Sglebiuskalenderv��sen" by Lars-Olof Lod��n (1968). 686309568Sglebius 687309568Sglebius 688309568SglebiusGrotefend's data 689309568Sglebius 690309568SglebiusFrom: "Michael Palmer" [with one obvious typo fixed] 691309568SglebiusSubject: Re: Gregorian Calendar (was Re: Another FHC related question 692309568SglebiusNewsgroups: soc.genealogy.german 693309568SglebiusDate: Tue, 9 Feb 1999 02:32:48 -800 694309568Sglebius... 695309568Sglebius 696309568SglebiusThe following is a(n incomplete) listing, arranged chronologically, of 697309568SglebiusEuropean states, with the date they converted from the Julian to the 698309568SglebiusGregorian calendar: 699309568Sglebius 700309568Sglebius04/15 Oct 1582 - Italy (with exceptions), Spain, Portugal, Poland (Roman 701309568Sglebius Catholics and Danzig only) 702309568Sglebius09/20 Dec 1582 - France, Lorraine 703309568Sglebius 704309568Sglebius21 Dec 1582/ 705309568Sglebius 01 Jan 1583 - Holland, Brabant, Flanders, Hennegau 706309568Sglebius10/21 Feb 1583 - bishopric of Liege (L��ttich) 707309568Sglebius13/24 Feb 1583 - bishopric of Augsburg 708309568Sglebius04/15 Oct 1583 - electorate of Trier 709309568Sglebius05/16 Oct 1583 - Bavaria, bishoprics of Freising, Eichstedt, Regensburg, 710309568Sglebius Salzburg, Brixen 711309568Sglebius13/24 Oct 1583 - Austrian Oberelsa�� and Breisgau 712309568Sglebius20/31 Oct 1583 - bishopric of Basel 713309568Sglebius02/13 Nov 1583 - duchy of J��lich-Berg 714309568Sglebius02/13 Nov 1583 - electorate and city of K��ln 715309568Sglebius04/15 Nov 1583 - bishopric of W��rzburg 716309568Sglebius11/22 Nov 1583 - electorate of Mainz 717309568Sglebius16/27 Nov 1583 - bishopric of Strassburg and the margraviate of Baden 718309568Sglebius17/28 Nov 1583 - bishopric of M��nster and duchy of Cleve 719309568Sglebius14/25 Dec 1583 - Steiermark 720309568Sglebius 721309568Sglebius06/17 Jan 1584 - Austria and Bohemia 722309568Sglebius11/22 Jan 1584 - Lucerne, Uri, Schwyz, Zug, Freiburg, Solothurn 723309568Sglebius12/23 Jan 1584 - Silesia and the Lausitz 724309568Sglebius22 Jan/ 725309568Sglebius 02 Feb 1584 - Hungary (legally on 21 Oct 1587) 726309568Sglebius Jun 1584 - Unterwalden 727309568Sglebius01/12 Jul 1584 - duchy of Westfalen 728309568Sglebius 729309568Sglebius16/27 Jun 1585 - bishopric of Paderborn 730309568Sglebius 731309568Sglebius14/25 Dec 1590 - Transylvania 732309568Sglebius 733309568Sglebius22 Aug/ 734309568Sglebius 02 Sep 1612 - duchy of Prussia 735309568Sglebius 736309568Sglebius13/24 Dec 1614 - Pfalz-Neuburg 737309568Sglebius 738309568Sglebius 1617 - duchy of Kurland (reverted to the Julian calendar in 739309568Sglebius 1796) 740309568Sglebius 741309568Sglebius 1624 - bishopric of Osnabr��ck 742309568Sglebius 743309568Sglebius 1630 - bishopric of Minden 744309568Sglebius 745309568Sglebius15/26 Mar 1631 - bishopric of Hildesheim 746309568Sglebius 747309568Sglebius 1655 - Kanton Wallis 748309568Sglebius 749309568Sglebius05/16 Feb 1682 - city of Strassburg 750309568Sglebius 751309568Sglebius18 Feb/ 752309568Sglebius 01 Mar 1700 - Protestant Germany (including Swedish possessions in 753309568Sglebius Germany), Denmark, Norway 754309568Sglebius30 Jun/ 755309568Sglebius 12 Jul 1700 - Gelderland, Zutphen 756309568Sglebius10 Nov/ 757309568Sglebius 12 Dec 1700 - Utrecht, Overijssel 758309568Sglebius 759309568Sglebius31 Dec 1700/ 760309568Sglebius 12 Jan 1701 - Friesland, Groningen, Z��rich, Bern, Basel, Geneva, 761309568Sglebius Turgau, and Schaffhausen 762309568Sglebius 763309568Sglebius 1724 - Glarus, Appenzell, and the city of St. Gallen 764309568Sglebius 765309568Sglebius01 Jan 1750 - Pisa and Florence 766309568Sglebius 767309568Sglebius02/14 Sep 1752 - Great Britain 768309568Sglebius 769309568Sglebius17 Feb/ 770309568Sglebius 01 Mar 1753 - Sweden 771309568Sglebius 772309568Sglebius1760-1812 - Graub��nden 773309568Sglebius 774309568SglebiusThe Russian empire (including Finland and the Baltic states) did not 775309568Sglebiusconvert to the Gregorian calendar until the Soviet revolution of 1917. 776309568Sglebius 777309568SglebiusSource: H. Grotefend, _Taschenbuch der Zeitrechnung des deutschen 778309568SglebiusMittelalters und der Neuzeit_, herausgegeben von Dr. O. Grotefend 779309568Sglebius(Hannover: Hahnsche Buchhandlung, 1941), pp. 26-28. 780309568Sglebius 781309568Sglebius 782309568Sglebius----- Time and time zones on Mars ----- 783309568Sglebius 784309568SglebiusSome people's work schedules use Mars time. Jet Propulsion Laboratory 785309568Sglebius(JPL) coordinators have kept Mars time on and off at least since 1997 786309568Sglebiusfor the Mars Pathfinder mission. Some of their family members have 787309568Sglebiusalso adapted to Mars time. Dozens of special Mars watches were built 788309568Sglebiusfor JPL workers who kept Mars time during the Mars Exploration 789309568SglebiusRovers mission (2004). These timepieces look like normal Seikos and 790309568SglebiusCitizens but use Mars seconds rather than terrestrial seconds. 791309568Sglebius 792309568SglebiusA Mars solar day is called a "sol" and has a mean period equal to 793309568Sglebiusabout 24 hours 39 minutes 35.244 seconds in terrestrial time. It is 794309568Sglebiusdivided into a conventional 24-hour clock, so each Mars second equals 795309568Sglebiusabout 1.02749125 terrestrial seconds. 796309568Sglebius 797309568SglebiusThe prime meridian of Mars goes through the center of the crater 798309568SglebiusAiry-0, named in honor of the British astronomer who built the 799309568SglebiusGreenwich telescope that defines Earth's prime meridian. Mean solar 800309568Sglebiustime on the Mars prime meridian is called Mars Coordinated Time (MTC). 801309568Sglebius 802309568SglebiusEach landed mission on Mars has adopted a different reference for 803309568Sglebiussolar time keeping, so there is no real standard for Mars time zones. 804309568SglebiusFor example, the Mars Exploration Rover project (2004) defined two 805309568Sglebiustime zones "Local Solar Time A" and "Local Solar Time B" for its two 806309568Sglebiusmissions, each zone designed so that its time equals local true solar 807309568Sglebiustime at approximately the middle of the nominal mission. Such a "time 808309568Sglebiuszone" is not particularly suited for any application other than the 809309568Sglebiusmission itself. 810309568Sglebius 811309568SglebiusMany calendars have been proposed for Mars, but none have achieved 812309568Sglebiuswide acceptance. Astronomers often use Mars Sol Date (MSD) which is a 813309568Sglebiussequential count of Mars solar days elapsed since about 1873-12-29 814309568Sglebius12:00 GMT. 815309568Sglebius 816309568SglebiusThe tz database does not currently support Mars time, but it is 817309568Sglebiusdocumented here in the hopes that support will be added eventually. 818309568Sglebius 819309568SglebiusSources: 820309568Sglebius 821309568SglebiusMichael Allison and Robert Schmunk, 822309568Sglebius"Technical Notes on Mars Solar Time as Adopted by the Mars24 Sunclock" 823309568Sglebius<http://www.giss.nasa.gov/tools/mars24/help/notes.html> (2012-08-08). 824309568Sglebius 825309568SglebiusJia-Rui Chong, "Workdays Fit for a Martian", Los Angeles Times 826309568Sglebius<http://articles.latimes.com/2004/jan/14/science/sci-marstime14> 827309568Sglebius(2004-01-14), pp A1, A20-A21. 828309568Sglebius 829309568SglebiusTom Chmielewski, "Jet Lag Is Worse on Mars", The Atlantic (2015-02-26) 830309568Sglebius<http://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/> 831309568Sglebius 832309568Sglebius----- 833309568Sglebius 834309568SglebiusThis file is in the public domain, so clarified as of 2009-05-17 by 835309568SglebiusArthur David Olson. 836309568Sglebius 837309568Sglebius----- 838309568SglebiusLocal Variables: 839309568Sglebiuscoding: utf-8 840309568SglebiusEnd: 841