theory.html revision 1.23 1 1.4 christos <!DOCTYPE html>
2 1.1 christos <html lang="en">
3 1.1 christos <head>
4 1.1 christos <title>Theory and pragmatics of the tz code and data</title>
5 1.1 christos <meta charset="UTF-8">
6 1.23 christos <meta name="viewport" content="width=device-width, initial-scale=1">
7 1.4 christos <style>
8 1.23 christos dd {margin-left: 1.3rem;}
9 1.23 christos pre {margin-left: 1.3rem; overflow: auto;}
10 1.23 christos ul {padding-left: 1.3rem;}
11 1.4 christos </style>
12 1.1 christos </head>
13 1.1 christos
14 1.1 christos <body>
15 1.3 christos <h1>Theory and pragmatics of the <code><abbr>tz</abbr></code> code and data</h1>
16 1.1 christos <nav>
17 1.1 christos <ul>
18 1.3 christos <li><a href="#scope">Scope of the <code><abbr>tz</abbr></code>
19 1.3 christos database</a></li>
20 1.7 christos <li><a href="#naming">Timezone identifiers</a></li>
21 1.1 christos <li><a href="#abbreviations">Time zone abbreviations</a></li>
22 1.3 christos <li><a href="#accuracy">Accuracy of the <code><abbr>tz</abbr></code>
23 1.3 christos database</a></li>
24 1.1 christos <li><a href="#functions">Time and date functions</a></li>
25 1.1 christos <li><a href="#stability">Interface stability</a></li>
26 1.9 christos <li><a href="#leapsec">Leap seconds</a></li>
27 1.1 christos <li><a href="#calendar">Calendrical issues</a></li>
28 1.18 christos <li><a href="#planets">Time and time zones off earth</a></li>
29 1.1 christos </ul>
30 1.1 christos </nav>
31 1.1 christos
32 1.3 christos <section>
33 1.3 christos <h2 id="scope">Scope of the <code><abbr>tz</abbr></code> database</h2>
34 1.1 christos <p>
35 1.3 christos The <a
36 1.3 christos href="https://www.iana.org/time-zones"><code><abbr>tz</abbr></code>
37 1.3 christos database</a> attempts to record the history and predicted future of
38 1.10 christos civil time scales.
39 1.3 christos It organizes <a href="tz-link.html">time zone and daylight saving time
40 1.3 christos data</a> by partitioning the world into <a
41 1.4 christos href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"><dfn>timezones</dfn></a>
42 1.3 christos whose clocks all agree about timestamps that occur after the <a
43 1.3 christos href="https://en.wikipedia.org/wiki/Unix_time">POSIX Epoch</a>
44 1.3 christos (1970-01-01 00:00:00 <a
45 1.3 christos href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time"><abbr
46 1.3 christos title="Coordinated Universal Time">UTC</abbr></a>).
47 1.3 christos Although 1970 is a somewhat-arbitrary cutoff, there are significant
48 1.3 christos challenges to moving the cutoff earlier even by a decade or two, due
49 1.3 christos to the wide variety of local practices before computer timekeeping
50 1.3 christos became prevalent.
51 1.12 christos Most timezones correspond to a notable location and the database
52 1.12 christos records all known clock transitions for that location;
53 1.12 christos some timezones correspond instead to a fixed <abbr>UTC</abbr> offset.
54 1.1 christos </p>
55 1.1 christos
56 1.1 christos <p>
57 1.4 christos Each timezone typically corresponds to a geographical region that is
58 1.4 christos smaller than a traditional time zone, because clocks in a timezone
59 1.4 christos all agree after 1970 whereas a traditional time zone merely
60 1.4 christos specifies current standard time. For example, applications that deal
61 1.4 christos with current and future timestamps in the traditional North
62 1.4 christos American mountain time zone can choose from the timezones
63 1.4 christos <code>America/Denver</code> which observes US-style daylight saving
64 1.12 christos time (<abbr>DST</abbr>),
65 1.12 christos and <code>America/Phoenix</code> which does not observe <abbr>DST</abbr>.
66 1.4 christos Applications that also deal with past timestamps in the mountain time
67 1.4 christos zone can choose from over a dozen timezones, such as
68 1.4 christos <code>America/Boise</code>, <code>America/Edmonton</code>, and
69 1.4 christos <code>America/Hermosillo</code>, each of which currently uses mountain
70 1.4 christos time but differs from other timezones for some timestamps after 1970.
71 1.4 christos </p>
72 1.4 christos
73 1.4 christos <p>
74 1.12 christos Clock transitions before 1970 are recorded for location-based timezones,
75 1.1 christos because most systems support timestamps before 1970 and could
76 1.1 christos misbehave if data entries were omitted for pre-1970 transitions.
77 1.1 christos However, the database is not designed for and does not suffice for
78 1.1 christos applications requiring accurate handling of all past times everywhere,
79 1.1 christos as it would take far too much effort and guesswork to record all
80 1.1 christos details of pre-1970 civil timekeeping.
81 1.3 christos Although some information outside the scope of the database is
82 1.2 christos collected in a file <code>backzone</code> that is distributed along
83 1.2 christos with the database proper, this file is less reliable and does not
84 1.2 christos necessarily follow database guidelines.
85 1.1 christos </p>
86 1.1 christos
87 1.1 christos <p>
88 1.3 christos As described below, reference source code for using the
89 1.3 christos <code><abbr>tz</abbr></code> database is also available.
90 1.3 christos The <code><abbr>tz</abbr></code> code is upwards compatible with <a
91 1.3 christos href="https://en.wikipedia.org/wiki/POSIX">POSIX</a>, an international
92 1.3 christos standard for <a
93 1.3 christos href="https://en.wikipedia.org/wiki/Unix">UNIX</a>-like systems.
94 1.22 christos As of this writing, the current edition of POSIX is
95 1.22 christos <a href="https://pubs.opengroup.org/onlinepubs/9799919799/">POSIX.1-2024</a>
96 1.22 christos (The Open Group Base Specifications Issue 8, IEEE Std 1003.1-2024).
97 1.22 christos Unlike its predecessors
98 1.22 christos <a href="https://archive.org/details/POSIX.1-1988">POSIX.1-1988</a> through
99 1.22 christos <a href="https://pubs.opengroup.org/onlinepubs/9699919799/">POSIX.1-2017</a>,
100 1.22 christos POSIX.1-2024 requires support for the
101 1.20 christos <code><abbr>tz</abbr></code> database, which has a
102 1.20 christos model for describing civil time that is more complex than the
103 1.22 christos standard and daylight saving times required by earlier POSIX editions.
104 1.4 christos A <code><abbr>tz</abbr></code> timezone corresponds to a ruleset that can
105 1.3 christos have more than two changes per year, these changes need not merely
106 1.3 christos flip back and forth between two alternatives, and the rules themselves
107 1.3 christos can change at times.
108 1.9 christos Whether and when a timezone changes its clock,
109 1.22 christos and even the timezones notional base offset from <abbr>UTC</abbr>,
110 1.9 christos are variable.
111 1.22 christos It does not always make sense to talk about a timezones
112 1.22 christos base offset, which is not necessarily a single number.
113 1.1 christos </p>
114 1.1 christos
115 1.3 christos </section>
116 1.1 christos
117 1.3 christos <section>
118 1.7 christos <h2 id="naming">Timezone identifiers</h2>
119 1.1 christos <p>
120 1.7 christos Each timezone has a name that uniquely identifies the timezone.
121 1.1 christos Inexperienced users are not expected to select these names unaided.
122 1.1 christos Distributors should provide documentation and/or a simple selection
123 1.4 christos interface that explains each name via a map or via descriptive text like
124 1.22 christos Czech Republic instead of the timezone name <code>Europe/Prague</code>.
125 1.4 christos If geolocation information is available, a selection interface can
126 1.4 christos locate the user on a timezone map or prioritize names that are
127 1.4 christos geographically close. For an example selection interface, see the
128 1.3 christos <code>tzselect</code> program in the <code><abbr>tz</abbr></code> code.
129 1.22 christos Unicodes <a href="https://cldr.unicode.org">Common Locale Data
130 1.21 christos Repository (<abbr>CLDR</abbr>)</a>
131 1.21 christos contains data that may be useful for other selection
132 1.10 christos interfaces; it maps timezone names like <code>Europe/Prague</code> to
133 1.22 christos locale-dependent strings like Prague, Praha, , and .
134 1.1 christos </p>
135 1.1 christos
136 1.1 christos <p>
137 1.3 christos The naming conventions attempt to strike a balance
138 1.1 christos among the following goals:
139 1.1 christos </p>
140 1.3 christos
141 1.1 christos <ul>
142 1.1 christos <li>
143 1.4 christos Uniquely identify every timezone where clocks have agreed since 1970.
144 1.3 christos This is essential for the intended use: static clocks keeping local
145 1.3 christos civil time.
146 1.1 christos </li>
147 1.1 christos <li>
148 1.22 christos Indicate to experts where the timezones clocks typically are.
149 1.1 christos </li>
150 1.1 christos <li>
151 1.3 christos Be robust in the presence of political changes.
152 1.7 christos For example, names are typically not tied to countries, to avoid
153 1.3 christos incompatibilities when countries change their name (e.g.,
154 1.22 christos SwazilandEswatini) or when locations change countries (e.g., Hong
155 1.3 christos Kong from UK colony to China).
156 1.7 christos There is no requirement that every country or national
157 1.7 christos capital must have a timezone name.
158 1.1 christos </li>
159 1.1 christos <li>
160 1.3 christos Be portable to a wide variety of implementations.
161 1.1 christos </li>
162 1.1 christos <li>
163 1.3 christos Use a consistent naming conventions over the entire world.
164 1.1 christos </li>
165 1.1 christos </ul>
166 1.3 christos
167 1.1 christos <p>
168 1.20 christos Names normally have the format
169 1.3 christos <var>AREA</var><code>/</code><var>LOCATION</var>, where
170 1.4 christos <var>AREA</var> is a continent or ocean, and
171 1.4 christos <var>LOCATION</var> is a specific location within the area.
172 1.22 christos North and South America share the same area, <code>America</code>.
173 1.22 christos Typical names are <code>Africa/Cairo</code>,
174 1.22 christos <code>America/New_York</code>, and <code>Pacific/Honolulu</code>.
175 1.3 christos Some names are further qualified to help avoid confusion; for example,
176 1.22 christos <code>America/Indiana/Petersburg</code> distinguishes Petersburg,
177 1.3 christos Indiana from other Petersburgs in America.
178 1.1 christos </p>
179 1.1 christos
180 1.1 christos <p>
181 1.3 christos Here are the general guidelines used for
182 1.4 christos choosing timezone names,
183 1.1 christos in decreasing order of importance:
184 1.1 christos </p>
185 1.3 christos
186 1.1 christos <ul>
187 1.1 christos <li>
188 1.3 christos Use only valid POSIX file name components (i.e., the parts of
189 1.22 christos names other than "<code>/</code>").
190 1.22 christos Do not use the file name components "<code>.</code>" and
191 1.22 christos "<code>..</code>".
192 1.3 christos Within a file name component, use only <a
193 1.3 christos href="https://en.wikipedia.org/wiki/ASCII">ASCII</a> letters,
194 1.22 christos "<code>.</code>", "<code>-</code>" and "<code>_</code>".
195 1.3 christos Do not use digits, as that might create an ambiguity with <a
196 1.22 christos href="https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html#tag_08_03">POSIXs
197 1.22 christos proleptic <code>TZ</code> strings</a>.
198 1.3 christos A file name component must not exceed 14 characters or start with
199 1.22 christos "<code>-</code>".
200 1.12 christos E.g., prefer <code>America/Noronha</code> to
201 1.12 christos <code>America/Fernando_de_Noronha</code>.
202 1.3 christos Exceptions: see the discussion of legacy names below.
203 1.1 christos </li>
204 1.1 christos <li>
205 1.22 christos A name must not be empty, or contain "<code>//</code>", or
206 1.22 christos start or end with "<code>/</code>".
207 1.22 christos Also, a name must not be "<code>Etc/Unknown</code>", as
208 1.21 christos <abbr>CLDR</abbr> uses that string for an unknown or invalid timezone.
209 1.1 christos </li>
210 1.1 christos <li>
211 1.3 christos Do not use names that differ only in case.
212 1.3 christos Although the reference implementation is case-sensitive, some
213 1.3 christos other implementations are not, and they would mishandle names
214 1.3 christos differing only in case.
215 1.1 christos </li>
216 1.1 christos <li>
217 1.3 christos If one name <var>A</var> is an initial prefix of another
218 1.3 christos name <var>AB</var> (ignoring case), then <var>B</var> must not
219 1.22 christos start with "<code>/</code>", as a regular file cannot have the
220 1.3 christos same name as a directory in POSIX.
221 1.3 christos For example, <code>America/New_York</code> precludes
222 1.3 christos <code>America/New_York/Bronx</code>.
223 1.1 christos </li>
224 1.1 christos <li>
225 1.3 christos Uninhabited regions like the North Pole and Bouvet Island
226 1.3 christos do not need locations, since local time is not defined there.
227 1.1 christos </li>
228 1.1 christos <li>
229 1.21 christos If all clocks in a region have agreed since 1970,
230 1.21 christos give them just one name even if some of the clocks disagreed before 1970,
231 1.21 christos or reside in different countries or in notable or faraway locations.
232 1.3 christos Otherwise these tables would become annoyingly large.
233 1.21 christos For example, do not create a name <code>Indian/Crozet</code>
234 1.21 christos as a near-duplicate or alias of <code>Asia/Dubai</code>
235 1.21 christos merely because they are different countries or territories,
236 1.21 christos or their clocks disagreed before 1970, or the
237 1.21 christos <a href="https://en.wikipedia.org/wiki/Crozet_Islands">Crozet Islands</a>
238 1.21 christos are notable in their own right,
239 1.21 christos or the Crozet Islands are not adjacent to other locations
240 1.21 christos that use <code>Asia/Dubai</code>.
241 1.1 christos </li>
242 1.1 christos <li>
243 1.7 christos If boundaries between regions are fluid, such as during a war or
244 1.7 christos insurrection, do not bother to create a new timezone merely
245 1.7 christos because of yet another boundary change. This helps prevent table
246 1.7 christos bloat and simplifies maintenance.
247 1.7 christos </li>
248 1.7 christos <li>
249 1.3 christos If a name is ambiguous, use a less ambiguous alternative;
250 1.3 christos e.g., many cities are named San Jos and Georgetown, so
251 1.3 christos prefer <code>America/Costa_Rica</code> to
252 1.3 christos <code>America/San_Jose</code> and <code>America/Guyana</code>
253 1.3 christos to <code>America/Georgetown</code>.
254 1.1 christos </li>
255 1.1 christos <li>
256 1.3 christos Keep locations compact.
257 1.3 christos Use cities or small islands, not countries or regions, so that any
258 1.3 christos future changes do not split individual locations into different
259 1.4 christos timezones.
260 1.3 christos E.g., prefer <code>Europe/Paris</code> to <code>Europe/France</code>,
261 1.3 christos since
262 1.3 christos <a href="https://en.wikipedia.org/wiki/Time_in_France#History">France
263 1.3 christos has had multiple time zones</a>.
264 1.1 christos </li>
265 1.1 christos <li>
266 1.3 christos Use mainstream English spelling, e.g., prefer
267 1.4 christos <code>Europe/Rome</code> to <code>Europa/Roma</code>, and
268 1.3 christos prefer <code>Europe/Athens</code> to the Greek
269 1.4 christos <code>/</code> or the Romanized
270 1.4 christos <code>Evrpi/Athna</code>.
271 1.3 christos The POSIX file name restrictions encourage this guideline.
272 1.1 christos </li>
273 1.1 christos <li>
274 1.3 christos Use the most populous among locations in a region,
275 1.3 christos e.g., prefer <code>Asia/Shanghai</code> to
276 1.3 christos <code>Asia/Beijing</code>.
277 1.3 christos Among locations with similar populations, pick the best-known
278 1.3 christos location, e.g., prefer <code>Europe/Rome</code> to
279 1.3 christos <code>Europe/Milan</code>.
280 1.1 christos </li>
281 1.1 christos <li>
282 1.3 christos Use the singular form, e.g., prefer <code>Atlantic/Canary</code> to
283 1.3 christos <code>Atlantic/Canaries</code>.
284 1.1 christos </li>
285 1.1 christos <li>
286 1.22 christos Omit common suffixes like "<code>_Islands</code>" and
287 1.22 christos "<code>_City</code>", unless that would lead to ambiguity.
288 1.3 christos E.g., prefer <code>America/Cayman</code> to
289 1.3 christos <code>America/Cayman_Islands</code> and
290 1.3 christos <code>America/Guatemala</code> to
291 1.3 christos <code>America/Guatemala_City</code>, but prefer
292 1.3 christos <code>America/Mexico_City</code> to
293 1.3 christos <code>America/Mexico</code>
294 1.3 christos because <a href="https://en.wikipedia.org/wiki/Time_in_Mexico">the
295 1.3 christos country of Mexico has several time zones</a>.
296 1.1 christos </li>
297 1.1 christos <li>
298 1.22 christos Use "<code>_</code>" to represent a space.
299 1.1 christos </li>
300 1.1 christos <li>
301 1.22 christos Omit "<code>.</code>" from abbreviations in names.
302 1.3 christos E.g., prefer <code>Atlantic/St_Helena</code> to
303 1.3 christos <code>Atlantic/St._Helena</code>.
304 1.1 christos </li>
305 1.1 christos <li>
306 1.3 christos Do not change established names if they only marginally violate
307 1.3 christos the above guidelines.
308 1.3 christos For example, do not change the existing name <code>Europe/Rome</code> to
309 1.22 christos <code>Europe/Milan</code> merely because Milans population has grown
310 1.22 christos to be somewhat greater than Romes.
311 1.1 christos </li>
312 1.1 christos <li>
313 1.3 christos If a name is changed, put its old spelling in the
314 1.22 christos "<code>backward</code>" file as a link to the new spelling.
315 1.3 christos This means old spellings will continue to work.
316 1.9 christos Ordinarily a name change should occur only in the rare case when
317 1.22 christos a locations consensus English-language spelling changes; for example,
318 1.9 christos in 2008 <code>Asia/Calcutta</code> was renamed to <code>Asia/Kolkata</code>
319 1.9 christos due to long-time widespread use of the new city name instead of the old.
320 1.1 christos </li>
321 1.1 christos </ul>
322 1.1 christos
323 1.1 christos <p>
324 1.7 christos Guidelines have evolved with time, and names following old versions of
325 1.8 christos these guidelines might not follow the current version. When guidelines
326 1.7 christos have changed, old names continue to be supported. Guideline changes
327 1.7 christos have included the following:
328 1.1 christos </p>
329 1.1 christos
330 1.7 christos <ul>
331 1.7 christos <li>
332 1.7 christos Older versions of this package used a different naming scheme.
333 1.22 christos See the file "<code>backward</code>" for most of these older names
334 1.22 christos (e.g., <code>US/Eastern</code> instead of <code>America/New_York</code>).
335 1.1 christos The other old-fashioned names still supported are
336 1.22 christos <code>WET</code>, <code>CET</code>, <code>MET</code>, and
337 1.22 christos <code>EET</code> (see the file "<code>europe</code>").
338 1.7 christos </li>
339 1.1 christos
340 1.7 christos <li>
341 1.1 christos Older versions of this package defined legacy names that are
342 1.3 christos incompatible with the first guideline of location names, but which are
343 1.3 christos still supported.
344 1.3 christos These legacy names are mostly defined in the file
345 1.22 christos "<code>etcetera</code>".
346 1.22 christos Also, the file "<code>backward</code>" defines the legacy names
347 1.22 christos <code>Etc/GMT0</code>, <code>Etc/GMT-0</code>, <code>Etc/GMT+0</code>,
348 1.22 christos <code>GMT0</code>, <code>GMT-0</code> and <code>GMT+0</code>,
349 1.22 christos and the file "<code>northamerica</code>" defines the legacy names
350 1.22 christos <code>EST5EDT</code>, <code>CST6CDT</code>,
351 1.22 christos <code>MST7MDT</code>, and <code>PST8PDT</code>.
352 1.7 christos </li>
353 1.7 christos
354 1.7 christos <li>
355 1.8 christos Older versions of these guidelines said that
356 1.7 christos there should typically be at least one name for each <a
357 1.7 christos href="https://en.wikipedia.org/wiki/ISO_3166-1"><abbr
358 1.7 christos title="International Organization for Standardization">ISO</abbr>
359 1.7 christos 3166-1</a> officially assigned two-letter code for an inhabited
360 1.7 christos country or territory.
361 1.7 christos This old guideline has been dropped, as it was not needed to handle
362 1.7 christos timestamps correctly and it increased maintenance burden.
363 1.7 christos </li>
364 1.7 christos </ul>
365 1.7 christos
366 1.7 christos <p>
367 1.13 christos The file <code>zone1970.tab</code> lists geographical locations used
368 1.7 christos to name timezones.
369 1.7 christos It is intended to be an exhaustive list of names for geographic
370 1.7 christos regions as described above; this is a subset of the timezones in the data.
371 1.22 christos Although a <code>zone1970.tab</code> locations
372 1.7 christos <a href="https://en.wikipedia.org/wiki/Longitude">longitude</a>
373 1.7 christos corresponds to
374 1.7 christos its <a href="https://en.wikipedia.org/wiki/Local_mean_time">local mean
375 1.22 christos time (<abbr>LMT</abbr>)</a> offset with one hour for every 15
376 1.7 christos east longitude, this relationship is not exact.
377 1.13 christos The backward-compatibility file <code>zone.tab</code> is similar
378 1.13 christos but conforms to the older-version guidelines related to <abbr>ISO</abbr> 3166-1;
379 1.13 christos it lists only one country code per entry and unlike <code>zone1970.tab</code>
380 1.13 christos it can list names defined in <code>backward</code>.
381 1.19 christos Applications that process only timestamps from now on can instead use the file
382 1.19 christos <code>zonenow.tab</code>, which partitions the world more coarsely,
383 1.19 christos into regions where clocks agree now and in the predicted future;
384 1.19 christos this file is smaller and simpler than <code>zone1970.tab</code>
385 1.19 christos and <code>zone.tab</code>.
386 1.1 christos </p>
387 1.1 christos
388 1.1 christos <p>
389 1.13 christos The database defines each timezone name to be a zone, or a link to a zone.
390 1.13 christos The source file <code>backward</code> defines links for backward
391 1.13 christos compatibility; it does not define zones.
392 1.13 christos Although <code>backward</code> was originally designed to be optional,
393 1.13 christos nowadays distributions typically use it
394 1.13 christos and no great weight should be attached to whether a link
395 1.13 christos is defined in <code>backward</code> or in some other file.
396 1.13 christos The source file <code>etcetera</code> defines names that may be useful
397 1.20 christos on platforms that do not support proleptic <code>TZ</code> strings
398 1.20 christos like <code><+08>-8</code>;
399 1.13 christos no other source file other than <code>backward</code>
400 1.13 christos contains links to its zones.
401 1.22 christos One of <code>etcetera</code>s names is <code>Etc/UTC</code>,
402 1.13 christos used by functions like <code>gmtime</code> to obtain leap
403 1.13 christos second information on platforms that support leap seconds.
404 1.14 christos Another <code>etcetera</code> name, <code>GMT</code>,
405 1.14 christos is used by older code releases.
406 1.1 christos </p>
407 1.3 christos </section>
408 1.1 christos
409 1.3 christos <section>
410 1.3 christos <h2 id="abbreviations">Time zone abbreviations</h2>
411 1.1 christos <p>
412 1.1 christos When this package is installed, it generates time zone abbreviations
413 1.22 christos like <code>EST</code> to be compatible with human tradition and POSIX.
414 1.3 christos Here are the general guidelines used for choosing time zone abbreviations,
415 1.1 christos in decreasing order of importance:
416 1.3 christos </p>
417 1.3 christos
418 1.1 christos <ul>
419 1.1 christos <li>
420 1.3 christos Use three to six characters that are ASCII alphanumerics or
421 1.22 christos "<code>+</code>" or "<code>-</code>".
422 1.3 christos Previous editions of this database also used characters like
423 1.22 christos space and "<code>?</code>", but these characters have a
424 1.3 christos special meaning to the
425 1.3 christos <a href="https://en.wikipedia.org/wiki/Unix_shell">UNIX shell</a>
426 1.3 christos and cause commands like
427 1.22 christos "<code><a href="https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#set">set</a>
428 1.22 christos `<a href="https://pubs.opengroup.org/onlinepubs/9799919799/utilities/date.html">date</a>`</code>"
429 1.3 christos to have unexpected effects.
430 1.3 christos Previous editions of this guideline required upper-case letters, but the
431 1.3 christos Congressman who introduced
432 1.3 christos <a href="https://en.wikipedia.org/wiki/Chamorro_Time_Zone">Chamorro
433 1.22 christos Standard Time</a> preferred ChST, so lower-case letters are now allowed.
434 1.22 christos Also, POSIX from 2001 on relaxed the rule to allow "<code>-</code>",
435 1.22 christos "<code>+</code>", and alphanumeric characters from the portable
436 1.3 christos character set in the current locale.
437 1.22 christos In practice ASCII alphanumerics and "<code>+</code>" and
438 1.22 christos "<code>-</code>" are safe in all locales.
439 1.3 christos
440 1.3 christos <p>
441 1.3 christos In other words, in the C locale the POSIX extended regular
442 1.3 christos expression <code>[-+[:alnum:]]{3,6}</code> should match the
443 1.3 christos abbreviation.
444 1.20 christos This guarantees that all abbreviations could have been specified
445 1.20 christos explicitly by a POSIX proleptic <code>TZ</code> string.
446 1.3 christos </p>
447 1.3 christos </li>
448 1.3 christos <li>
449 1.3 christos Use abbreviations that are in common use among English-speakers,
450 1.22 christos e.g., EST for Eastern Standard Time in North America.
451 1.3 christos We assume that applications translate them to other languages
452 1.3 christos as part of the normal localization process; for example,
453 1.22 christos a French application might translate EST to HNE.
454 1.3 christos
455 1.3 christos <p>
456 1.3 christos <small>These abbreviations (for standard/daylight/etc. time) are:
457 1.3 christos ACST/ACDT Australian Central,
458 1.3 christos AST/ADT/APT/AWT/ADDT Atlantic,
459 1.3 christos AEST/AEDT Australian Eastern,
460 1.3 christos AHST/AHDT Alaska-Hawaii,
461 1.3 christos AKST/AKDT Alaska,
462 1.3 christos AWST/AWDT Australian Western,
463 1.3 christos BST/BDT Bering,
464 1.3 christos CAT/CAST Central Africa,
465 1.3 christos CET/CEST/CEMT Central European,
466 1.3 christos ChST Chamorro,
467 1.18 christos CST/CDT/CWT/CPT Central [North America],
468 1.3 christos CST/CDT China,
469 1.3 christos GMT/BST/IST/BDST Greenwich,
470 1.3 christos EAT East Africa,
471 1.18 christos EST/EDT/EWT/EPT Eastern [North America],
472 1.3 christos EET/EEST Eastern European,
473 1.6 christos GST/GDT Guam,
474 1.5 christos HST/HDT/HWT/HPT Hawaii,
475 1.9 christos HKT/HKST/HKWT Hong Kong,
476 1.3 christos IST India,
477 1.3 christos IST/GMT Irish,
478 1.3 christos IST/IDT/IDDT Israel,
479 1.3 christos JST/JDT Japan,
480 1.3 christos KST/KDT Korea,
481 1.3 christos MET/MEST Middle European (a backward-compatibility alias for
482 1.3 christos Central European),
483 1.3 christos MSK/MSD Moscow,
484 1.18 christos MST/MDT/MWT/MPT Mountain,
485 1.3 christos NST/NDT/NWT/NPT/NDDT Newfoundland,
486 1.3 christos NST/NDT/NWT/NPT Nome,
487 1.3 christos NZMT/NZST New Zealand through 1945,
488 1.22 christos NZST/NZDT New Zealand 1946present,
489 1.3 christos PKT/PKST Pakistan,
490 1.18 christos PST/PDT/PWT/PPT Pacific,
491 1.4 christos PST/PDT Philippine,
492 1.3 christos SAST South Africa,
493 1.3 christos SST Samoa,
494 1.14 christos UTC Universal,
495 1.3 christos WAT/WAST West Africa,
496 1.3 christos WET/WEST/WEMT Western European,
497 1.3 christos WIB Waktu Indonesia Barat,
498 1.3 christos WIT Waktu Indonesia Timur,
499 1.3 christos WITA Waktu Indonesia Tengah,
500 1.3 christos YST/YDT/YWT/YPT/YDDT Yukon</small>.
501 1.3 christos </p>
502 1.3 christos </li>
503 1.3 christos <li>
504 1.3 christos <p>
505 1.22 christos For times taken from a citys longitude, use the
506 1.3 christos traditional <var>x</var>MT notation.
507 1.22 christos The only abbreviation like this in current use is <abbr>GMT</abbr>.
508 1.3 christos The others are for timestamps before 1960,
509 1.3 christos except that Monrovia Mean Time persisted until 1972.
510 1.22 christos Typically, numeric abbreviations (e.g., <code>-</code>004430 for
511 1.3 christos MMT) would cause trouble here, as the numeric strings would exceed
512 1.3 christos the POSIX length limit.
513 1.3 christos </p>
514 1.3 christos
515 1.3 christos <p>
516 1.3 christos <small>These abbreviations are:
517 1.12 christos AMT Asuncin, Athens;
518 1.18 christos BMT Baghdad, Bangkok, Batavia, Bermuda, Bern, Bogot,
519 1.11 christos Brussels, Bucharest;
520 1.12 christos CMT Calamarca, Caracas, Chisinau, Coln, Crdoba;
521 1.3 christos DMT Dublin/Dunsink;
522 1.3 christos EMT Easter;
523 1.3 christos FFMT Fort-de-France;
524 1.3 christos FMT Funchal;
525 1.3 christos GMT Greenwich;
526 1.3 christos HMT Havana, Helsinki, Horta, Howrah;
527 1.3 christos IMT Irkutsk, Istanbul;
528 1.3 christos JMT Jerusalem;
529 1.14 christos KMT Kaunas, Kyiv, Kingston;
530 1.18 christos LMT Lima, Lisbon, local;
531 1.3 christos MMT Macassar, Madras, Mal, Managua, Minsk, Monrovia, Montevideo,
532 1.3 christos Moratuwa, Moscow;
533 1.3 christos PLMT Ph Lin;
534 1.3 christos PMT Paramaribo, Paris, Perm, Pontianak, Prague;
535 1.3 christos PMMT Port Moresby;
536 1.18 christos PPMT Port-au-Prince;
537 1.3 christos QMT Quito;
538 1.3 christos RMT Rangoon, Riga, Rome;
539 1.3 christos SDMT Santo Domingo;
540 1.3 christos SJMT San Jos;
541 1.3 christos SMT Santiago, Simferopol, Singapore, Stanley;
542 1.3 christos TBMT Tbilisi;
543 1.3 christos TMT Tallinn, Tehran;
544 1.18 christos WMT Warsaw.</small>
545 1.3 christos </p>
546 1.3 christos
547 1.3 christos <p>
548 1.3 christos <small>A few abbreviations also follow the pattern that
549 1.4 christos <abbr>GMT</abbr>/<abbr>BST</abbr> established for time in the UK.
550 1.3 christos They are:
551 1.22 christos BMT/BST for Bermuda 18901930,
552 1.3 christos CMT/BST for Calamarca Mean Time and Bolivian Summer Time
553 1.22 christos 18901932,
554 1.3 christos DMT/IST for Dublin/Dunsink Mean Time and Irish Summer Time
555 1.22 christos 18801916,
556 1.22 christos MMT/MST/MDST for Moscow 18801919, and
557 1.22 christos RMT/LST for Riga Mean Time and Latvian Summer time 18801926.
558 1.12 christos </small>
559 1.3 christos </p>
560 1.3 christos </li>
561 1.3 christos <li>
562 1.22 christos Use <abbr>LMT</abbr> for local mean time of locations before the
563 1.22 christos introduction of standard time; see <a href="#scope">Scope of the
564 1.22 christos <code><abbr>tz</abbr></code> database</a>.
565 1.3 christos </li>
566 1.3 christos <li>
567 1.3 christos If there is no common English abbreviation, use numeric offsets like
568 1.4 christos <code>-</code>05 and <code>+</code>0530 that are generated
569 1.22 christos by <code>zic</code>s <code>%z</code> notation.
570 1.3 christos </li>
571 1.3 christos <li>
572 1.3 christos Use current abbreviations for older timestamps to avoid confusion.
573 1.3 christos For example, in 1910 a common English abbreviation for time
574 1.22 christos in central Europe was MEZ (short for both Middle European
575 1.22 christos Zone and for Mitteleuropische Zeit in German).
576 1.22 christos Nowadays CET (Central European Time) is more common in
577 1.22 christos English, and the database uses CET even for circa-1910
578 1.3 christos timestamps as this is less confusing for modern users and avoids
579 1.22 christos the need for determining when CET supplanted MEZ in common
580 1.3 christos usage.
581 1.3 christos </li>
582 1.3 christos <li>
583 1.22 christos Use a consistent style in a timezones history.
584 1.4 christos For example, if a history tends to use numeric
585 1.3 christos abbreviations and a particular entry could go either way, use a
586 1.3 christos numeric abbreviation.
587 1.3 christos </li>
588 1.3 christos <li>
589 1.3 christos Use
590 1.3 christos <a href="https://en.wikipedia.org/wiki/Universal_Time">Universal Time</a>
591 1.22 christos (<abbr>UT</abbr>) (with time zone abbreviation <code>-</code>00) for
592 1.3 christos locations while uninhabited.
593 1.22 christos The leading "<code>-</code>" is a flag that the <abbr>UT</abbr> offset is in
594 1.3 christos some sense undefined; this notation is derived
595 1.21 christos from <a href="https://www.rfc-editor.org/rfc/rfc3339">Internet
596 1.4 christos <abbr title="Request For Comments">RFC</abbr> 3339</a>.
597 1.22 christos (The abbreviation Z that
598 1.21 christos <a href="https://www.rfc-editor.org/rfc/rfc9557">Internet
599 1.20 christos <abbr>RFC</abbr> 9557</a> uses for this concept
600 1.20 christos would violate the POSIX requirement
601 1.20 christos of at least three characters in an abbreviation.)
602 1.1 christos </li>
603 1.1 christos </ul>
604 1.3 christos
605 1.1 christos <p>
606 1.1 christos Application writers should note that these abbreviations are ambiguous
607 1.22 christos in practice: e.g., CST means one thing in China and something else
608 1.22 christos in North America, and IST can refer to time in India, Ireland or
609 1.3 christos Israel.
610 1.3 christos To avoid ambiguity, use numeric <abbr>UT</abbr> offsets like
611 1.22 christos <code>-</code>0600 instead of time zone abbreviations like CST.
612 1.1 christos </p>
613 1.3 christos </section>
614 1.1 christos
615 1.3 christos <section>
616 1.3 christos <h2 id="accuracy">Accuracy of the <code><abbr>tz</abbr></code> database</h2>
617 1.1 christos <p>
618 1.3 christos The <code><abbr>tz</abbr></code> database is not authoritative, and it
619 1.3 christos surely has errors.
620 1.2 christos Corrections are welcome and encouraged; see the file <code>CONTRIBUTING</code>.
621 1.1 christos Users requiring authoritative data should consult national standards
622 1.22 christos bodies and the references cited in the databases comments.
623 1.1 christos </p>
624 1.1 christos
625 1.1 christos <p>
626 1.3 christos Errors in the <code><abbr>tz</abbr></code> database arise from many sources:
627 1.1 christos </p>
628 1.3 christos
629 1.1 christos <ul>
630 1.1 christos <li>
631 1.3 christos The <code><abbr>tz</abbr></code> database predicts future
632 1.3 christos timestamps, and current predictions
633 1.3 christos will be incorrect after future governments change the rules.
634 1.3 christos For example, if today someone schedules a meeting for 13:00 next
635 1.3 christos October 1, Casablanca time, and tomorrow Morocco changes its
636 1.3 christos daylight saving rules, software can mess up after the rule change
637 1.3 christos if it blithely relies on conversions made before the change.
638 1.3 christos </li>
639 1.3 christos <li>
640 1.3 christos The pre-1970 entries in this database cover only a tiny sliver of how
641 1.3 christos clocks actually behaved; the vast majority of the necessary
642 1.3 christos information was lost or never recorded.
643 1.4 christos Thousands more timezones would be needed if
644 1.22 christos the <code><abbr>tz</abbr></code> databases scope were extended to
645 1.3 christos cover even just the known or guessed history of standard time; for
646 1.3 christos example, the current single entry for France would need to split
647 1.3 christos into dozens of entries, perhaps hundreds.
648 1.3 christos And in most of the world even this approach would be misleading
649 1.3 christos due to widespread disagreement or indifference about what times
650 1.3 christos should be observed.
651 1.3 christos In her 2015 book
652 1.3 christos <cite><a
653 1.23 christos href="https://www.hup.harvard.edu/books/9780674286146">The
654 1.22 christos Global Transformation of Time, 18701950</a></cite>,
655 1.3 christos Vanessa Ogle writes
656 1.22 christos Outside of Europe and North America there was no system of time
657 1.3 christos zones at all, often not even a stable landscape of mean times,
658 1.22 christos prior to the middle decades of the twentieth century.
659 1.3 christos See: Timothy Shenk, <a
660 1.23 christos href="https://dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle/">Booked:
661 1.3 christos A Global History of Time</a>. <cite>Dissent</cite> 2015-12-17.
662 1.3 christos </li>
663 1.3 christos <li>
664 1.3 christos Most of the pre-1970 data entries come from unreliable sources, often
665 1.3 christos astrology books that lack citations and whose compilers evidently
666 1.3 christos invented entries when the true facts were unknown, without
667 1.3 christos reporting which entries were known and which were invented.
668 1.3 christos These books often contradict each other or give implausible entries,
669 1.3 christos and on the rare occasions when they are checked they are
670 1.3 christos typically found to be incorrect.
671 1.3 christos </li>
672 1.3 christos <li>
673 1.3 christos For the UK the <code><abbr>tz</abbr></code> database relies on
674 1.3 christos years of first-class work done by
675 1.3 christos Joseph Myers and others; see
676 1.22 christos <a href="https://www.polyomino.org.uk/british-time/">History of
677 1.22 christos legal time in Britain</a>.
678 1.3 christos Other countries are not done nearly as well.
679 1.3 christos </li>
680 1.3 christos <li>
681 1.3 christos Sometimes, different people in the same city maintain clocks
682 1.3 christos that differ significantly.
683 1.3 christos Historically, railway time was used by railroad companies (which
684 1.3 christos did not always
685 1.3 christos agree with each other), church-clock time was used for birth
686 1.3 christos certificates, etc.
687 1.3 christos More recently, competing political groups might disagree about
688 1.3 christos clock settings. Often this is merely common practice, but
689 1.3 christos sometimes it is set by law.
690 1.3 christos For example, from 1891 to 1911 the <abbr>UT</abbr> offset in France
691 1.3 christos was legally <abbr>UT</abbr> +00:09:21 outside train stations and
692 1.3 christos <abbr>UT</abbr> +00:04:21 inside. Other examples include
693 1.3 christos Chillicothe in 1920, Palm Springs in 1946/7, and Jerusalem and
694 1.3 christos rmqi to this day.
695 1.3 christos </li>
696 1.3 christos <li>
697 1.3 christos Although a named location in the <code><abbr>tz</abbr></code>
698 1.3 christos database stands for the containing region, its pre-1970 data
699 1.3 christos entries are often accurate for only a small subset of that region.
700 1.3 christos For example, <code>Europe/London</code> stands for the United
701 1.3 christos Kingdom, but its pre-1847 times are valid only for locations that
702 1.22 christos have Londons exact meridian, and its 1847 transition
703 1.3 christos to <abbr>GMT</abbr> is known to be valid only for the L&NW and
704 1.3 christos the Caledonian railways.
705 1.3 christos </li>
706 1.3 christos <li>
707 1.3 christos The <code><abbr>tz</abbr></code> database does not record the
708 1.22 christos earliest time for which a timezones
709 1.3 christos data entries are thereafter valid for every location in the region.
710 1.3 christos For example, <code>Europe/London</code> is valid for all locations
711 1.3 christos in its region after <abbr>GMT</abbr> was made the standard time,
712 1.3 christos but the date of standardization (1880-08-02) is not in the
713 1.3 christos <code><abbr>tz</abbr></code> database, other than in commentary.
714 1.4 christos For many timezones the earliest time of
715 1.3 christos validity is unknown.
716 1.3 christos </li>
717 1.3 christos <li>
718 1.3 christos The <code><abbr>tz</abbr></code> database does not record a
719 1.22 christos regions boundaries, and in many cases the boundaries are not known.
720 1.4 christos For example, the timezone
721 1.3 christos <code>America/Kentucky/Louisville</code> represents a region
722 1.3 christos around the city of Louisville, the boundaries of which are
723 1.3 christos unclear.
724 1.3 christos </li>
725 1.3 christos <li>
726 1.3 christos Changes that are modeled as instantaneous transitions in the
727 1.3 christos <code><abbr>tz</abbr></code>
728 1.3 christos database were often spread out over hours, days, or even decades.
729 1.3 christos </li>
730 1.3 christos <li>
731 1.3 christos Even if the time is specified by law, locations sometimes
732 1.3 christos deliberately flout the law.
733 1.3 christos </li>
734 1.3 christos <li>
735 1.3 christos Early timekeeping practices, even assuming perfect clocks, were
736 1.3 christos often not specified to the accuracy that the
737 1.3 christos <code><abbr>tz</abbr></code> database requires.
738 1.3 christos </li>
739 1.3 christos <li>
740 1.10 christos The <code><abbr>tz</abbr></code> database cannot represent stopped clocks.
741 1.10 christos However, on 1911-03-11 at 00:00, some public-facing French clocks
742 1.10 christos were changed by stopping them for a few minutes to effect a transition.
743 1.10 christos The <code><abbr>tz</abbr></code> database models this via a
744 1.10 christos backward transition; the relevant French legislation does not
745 1.10 christos specify exactly how the transition was to occur.
746 1.10 christos </li>
747 1.10 christos <li>
748 1.3 christos Sometimes historical timekeeping was specified more precisely
749 1.3 christos than what the <code><abbr>tz</abbr></code> code can handle.
750 1.12 christos For example, from 1880 to 1916 clocks in Ireland observed Dublin Mean
751 1.3 christos Time (estimated to be <abbr>UT</abbr>
752 1.22 christos 00:25:21.1); although the <code><abbr>tz</abbr></code>
753 1.14 christos source data can represent the .1 second, TZif files and the code cannot.
754 1.3 christos In practice these old specifications were rarely if ever
755 1.3 christos implemented to subsecond precision.
756 1.3 christos </li>
757 1.3 christos <li>
758 1.3 christos Even when all the timestamp transitions recorded by the
759 1.3 christos <code><abbr>tz</abbr></code> database are correct, the
760 1.3 christos <code><abbr>tz</abbr></code> rules that generate them may not
761 1.3 christos faithfully reflect the historical rules.
762 1.3 christos For example, from 1922 until World War II the UK moved clocks
763 1.3 christos forward the day following the third Saturday in April unless that
764 1.3 christos was Easter, in which case it moved clocks forward the previous
765 1.3 christos Sunday.
766 1.3 christos Because the <code><abbr>tz</abbr></code> database has no
767 1.3 christos way to specify Easter, these exceptional years are entered as
768 1.3 christos separate <code><abbr>tz</abbr> Rule</code> lines, even though the
769 1.3 christos legal rules did not change.
770 1.4 christos When transitions are known but the historical rules behind them are not,
771 1.4 christos the database contains <code>Zone</code> and <code>Rule</code>
772 1.4 christos entries that are intended to represent only the generated
773 1.4 christos transitions, not any underlying historical rules; however, this
774 1.4 christos intent is recorded at best only in commentary.
775 1.3 christos </li>
776 1.3 christos <li>
777 1.4 christos The <code><abbr>tz</abbr></code> database models time
778 1.3 christos using the <a
779 1.3 christos href="https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar">proleptic
780 1.4 christos Gregorian calendar</a> with days containing 24 equal-length hours
781 1.4 christos numbered 00 through 23, except when clock transitions occur.
782 1.4 christos Pre-standard time is modeled as local mean time.
783 1.4 christos However, historically many people used other calendars and other timescales.
784 1.3 christos For example, the Roman Empire used
785 1.3 christos the <a href="https://en.wikipedia.org/wiki/Julian_calendar">Julian
786 1.3 christos calendar</a>,
787 1.3 christos and <a href="https://en.wikipedia.org/wiki/Roman_timekeeping">Roman
788 1.3 christos timekeeping</a> had twelve varying-length daytime hours with a
789 1.3 christos non-hour-based system at night.
790 1.4 christos And even today, some local practices diverge from the Gregorian
791 1.4 christos calendar with 24-hour days. These divergences range from
792 1.22 christos relatively minor, such as Japanese bars giving times like 24:30 for the
793 1.4 christos wee hours of the morning, to more-significant differences such as <a
794 1.23 christos href="https://theworld.org/stories/2015/01/30/ethiopian-time">the
795 1.4 christos east African practice of starting the day at dawn</a>, renumbering
796 1.4 christos the Western 06:00 to be 12:00. These practices are largely outside
797 1.4 christos the scope of the <code><abbr>tz</abbr></code> code and data, which
798 1.4 christos provide only limited support for date and time localization
799 1.20 christos such as that required by POSIX.
800 1.12 christos If <abbr>DST</abbr> is not used a different time zone
801 1.4 christos can often do the trick; for example, in Kenya a <code>TZ</code> setting
802 1.4 christos like <code><-03>3</code> or <code>America/Cayenne</code> starts
803 1.4 christos the day six hours later than <code>Africa/Nairobi</code> does.
804 1.3 christos </li>
805 1.3 christos <li>
806 1.3 christos Early clocks were less reliable, and data entries do not represent
807 1.3 christos clock error.
808 1.3 christos </li>
809 1.3 christos <li>
810 1.3 christos The <code><abbr>tz</abbr></code> database assumes Universal Time
811 1.3 christos (<abbr>UT</abbr>) as an origin, even though <abbr>UT</abbr> is not
812 1.3 christos standardized for older timestamps.
813 1.3 christos In the <code><abbr>tz</abbr></code> database commentary,
814 1.3 christos <abbr>UT</abbr> denotes a family of time standards that includes
815 1.3 christos Coordinated Universal Time (<abbr>UTC</abbr>) along with other
816 1.3 christos variants such as <abbr>UT1</abbr> and <abbr>GMT</abbr>,
817 1.3 christos with days starting at midnight.
818 1.3 christos Although <abbr>UT</abbr> equals <abbr>UTC</abbr> for modern
819 1.3 christos timestamps, <abbr>UTC</abbr> was not defined until 1960, so
820 1.18 christos commentary uses the more general abbreviation <abbr>UT</abbr> for
821 1.3 christos timestamps that might predate 1960.
822 1.3 christos Since <abbr>UT</abbr>, <abbr>UT1</abbr>, etc. disagree slightly,
823 1.3 christos and since pre-1972 <abbr>UTC</abbr> seconds varied in length,
824 1.3 christos interpretation of older timestamps can be problematic when
825 1.3 christos subsecond accuracy is needed.
826 1.3 christos </li>
827 1.3 christos <li>
828 1.3 christos Civil time was not based on atomic time before 1972, and we do not
829 1.3 christos know the history of
830 1.22 christos <a href="https://en.wikipedia.org/wiki/Earth's_rotation">earths
831 1.3 christos rotation</a> accurately enough to map <a
832 1.3 christos href="https://en.wikipedia.org/wiki/International_System_of_Units"><abbr
833 1.3 christos title="International System of Units">SI</abbr></a> seconds to
834 1.3 christos historical <a href="https://en.wikipedia.org/wiki/Solar_time">solar time</a>
835 1.3 christos to more than about one-hour accuracy.
836 1.22 christos See: Morrison LV, Stephenson FR, Hohenkerk CY, Zawilski M.
837 1.22 christos <a href="https://doi.org/10.1098/rspa.2020.0776">Addendum 2020
838 1.22 christos to Measurement of the Earths rotation: 720 BC to AD 2015</a>.
839 1.22 christos <cite>Proc Royal Soc A</cite>. 2021;477:20200776.
840 1.3 christos Also see: Espenak F. <a
841 1.3 christos href="https://eclipse.gsfc.nasa.gov/SEhelp/uncertainty2004.html">Uncertainty
842 1.3 christos in Delta T (T)</a>.
843 1.3 christos </li>
844 1.3 christos <li>
845 1.3 christos The relationship between POSIX time (that is, <abbr>UTC</abbr> but
846 1.3 christos ignoring <a href="https://en.wikipedia.org/wiki/Leap_second">leap
847 1.18 christos seconds</a>) and <abbr>UTC</abbr> is not agreed upon.
848 1.22 christos This affects time stamps during the leap second era (19722035).
849 1.3 christos Although the POSIX
850 1.3 christos clock officially stops during an inserted leap second, at least one
851 1.3 christos proposed standard has it jumping back a second instead; and in
852 1.3 christos practice POSIX clocks more typically either progress glacially during
853 1.3 christos a leap second, or are slightly slowed while near a leap second.
854 1.3 christos </li>
855 1.3 christos <li>
856 1.3 christos The <code><abbr>tz</abbr></code> database does not represent how
857 1.3 christos uncertain its information is.
858 1.3 christos Ideally it would contain information about when data entries are
859 1.3 christos incomplete or dicey.
860 1.3 christos Partial temporal knowledge is a field of active research, though,
861 1.3 christos and it is not clear how to apply it here.
862 1.1 christos </li>
863 1.1 christos </ul>
864 1.1 christos
865 1.1 christos <p>
866 1.3 christos In short, many, perhaps most, of the <code><abbr>tz</abbr></code>
867 1.22 christos databases pre-1970 and future timestamps are either wrong or
868 1.3 christos misleading.
869 1.3 christos Any attempt to pass the
870 1.3 christos <code><abbr>tz</abbr></code> database off as the definition of time
871 1.3 christos should be unacceptable to anybody who cares about the facts.
872 1.22 christos In particular, the <code><abbr>tz</abbr></code> databases
873 1.3 christos <abbr>LMT</abbr> offsets should not be considered meaningful, and
874 1.4 christos should not prompt creation of timezones
875 1.3 christos merely because two locations
876 1.3 christos differ in <abbr>LMT</abbr> or transitioned to standard time at
877 1.3 christos different dates.
878 1.3 christos </p>
879 1.3 christos </section>
880 1.3 christos
881 1.3 christos <section>
882 1.3 christos <h2 id="functions">Time and date functions</h2>
883 1.3 christos <p>
884 1.3 christos The <code><abbr>tz</abbr></code> code contains time and date functions
885 1.3 christos that are upwards compatible with those of POSIX.
886 1.3 christos Code compatible with this package is already
887 1.3 christos <a href="tz-link.html#tzdb">part of many platforms</a>, where the
888 1.3 christos primary use of this package is to update obsolete time-related files.
889 1.3 christos To do this, you may need to compile the time zone compiler
890 1.20 christos <code>zic</code> supplied with this package instead of using the
891 1.22 christos system <code>zic</code>, since the format of <code>zic</code>s
892 1.3 christos input is occasionally extended, and a platform may still be shipping
893 1.3 christos an older <code>zic</code>.
894 1.1 christos </p>
895 1.1 christos
896 1.20 christos <p>
897 1.20 christos In POSIX, time display in a process is controlled by the
898 1.20 christos environment variable <code>TZ</code>, which can have two forms:
899 1.20 christos </p>
900 1.1 christos <ul>
901 1.1 christos <li>
902 1.20 christos A <dfn>proleptic <code>TZ</code></dfn> value
903 1.20 christos like <code>CET-1CEST,M3.5.0,M10.5.0/3</code> uses a complex
904 1.20 christos notation that specifies a single standard time along with daylight
905 1.20 christos saving rules that apply to all years past, present, and future.
906 1.20 christos </li>
907 1.20 christos <li>
908 1.20 christos A <dfn>geographical <code>TZ</code></dfn> value
909 1.20 christos like <code>Europe/Berlin</code> names a location that stands for
910 1.20 christos civil time near that location, which can have more than
911 1.20 christos one standard time and more than one set of daylight saving rules,
912 1.20 christos to record timekeeping practice more accurately.
913 1.20 christos These names are defined by the <code><abbr>tz</abbr></code> database.
914 1.20 christos </li>
915 1.20 christos </ul>
916 1.20 christos
917 1.20 christos <h3 id="POSIX.1-2017">POSIX.1-2017 properties and limitations</h3>
918 1.20 christos <p>
919 1.22 christos Some platforms support only the features required by POSIX.1-2017
920 1.22 christos and earlier editions,
921 1.20 christos and have not yet upgraded to POSIX.1-2024.
922 1.20 christos Code intended to be portable to these platforms must deal
923 1.20 christos with problems that were fixed in later POSIX editions.
924 1.20 christos </p>
925 1.20 christos
926 1.20 christos <ul>
927 1.20 christos <li>
928 1.20 christos POSIX.1-2017 does not require support for geographical <code>TZ</code>,
929 1.20 christos and there is no convenient and efficient way to determine
930 1.20 christos the <abbr>UT</abbr> offset and time zone abbreviation of arbitrary
931 1.20 christos timestamps, particularly for timezones
932 1.20 christos that do not fit into the POSIX model.
933 1.20 christos </li>
934 1.20 christos <li>
935 1.1 christos <p>
936 1.20 christos The proleptic <code>TZ</code> string,
937 1.20 christos which is all that POSIX.1-2017 requires,
938 1.20 christos has a format that is hard to describe and is error-prone in practice.
939 1.20 christos Also, proleptic <code>TZ</code> strings cannot deal with daylight
940 1.3 christos saving time rules not based on the Gregorian calendar (as in
941 1.18 christos Morocco), or with situations where more than two time zone
942 1.3 christos abbreviations or <abbr>UT</abbr> offsets are used in an area.
943 1.1 christos </p>
944 1.3 christos
945 1.1 christos <p>
946 1.20 christos A proleptic <code>TZ</code> string has the following format:
947 1.1 christos </p>
948 1.3 christos
949 1.1 christos <p>
950 1.3 christos <var>stdoffset</var>[<var>dst</var>[<var>offset</var>][<code>,</code><var>date</var>[<code>/</code><var>time</var>]<code>,</code><var>date</var>[<code>/</code><var>time</var>]]]
951 1.1 christos </p>
952 1.3 christos
953 1.1 christos <p>
954 1.3 christos where:
955 1.3 christos </p>
956 1.3 christos
957 1.1 christos <dl>
958 1.1 christos <dt><var>std</var> and <var>dst</var></dt><dd>
959 1.3 christos are 3 or more characters specifying the standard
960 1.4 christos and daylight saving time (<abbr>DST</abbr>) zone abbreviations.
961 1.3 christos Starting with POSIX.1-2001, <var>std</var> and <var>dst</var>
962 1.22 christos may also be quoted in angle brackets, like <code><+09></code>;
963 1.3 christos this allows "<code>+</code>" and "<code>-</code>" in the names.
964 1.1 christos </dd>
965 1.1 christos <dt><var>offset</var></dt><dd>
966 1.3 christos is of the form
967 1.22 christos <code>[]<var>hh</var>:[<var>mm</var>[:<var>ss</var>]]</code>
968 1.3 christos and specifies the offset west of <abbr>UT</abbr>.
969 1.22 christos <var>hh</var> may be a single digit;
970 1.3 christos 0≤<var>hh</var>≤24.
971 1.3 christos The default <abbr>DST</abbr> offset is one hour ahead of
972 1.3 christos standard time.
973 1.1 christos </dd>
974 1.1 christos <dt><var>date</var>[<code>/</code><var>time</var>]<code>,</code><var>date</var>[<code>/</code><var>time</var>]</dt><dd>
975 1.3 christos specifies the beginning and end of <abbr>DST</abbr>.
976 1.3 christos If this is absent, the system supplies its own ruleset
977 1.18 christos for <abbr>DST</abbr>, typically current <abbr>US</abbr>
978 1.18 christos <abbr>DST</abbr> rules.
979 1.1 christos </dd>
980 1.1 christos <dt><var>time</var></dt><dd>
981 1.3 christos takes the form
982 1.22 christos <var>hh</var><code>:</code>[<var>mm</var>[<code>:</code><var>ss</var>]]
983 1.3 christos and defaults to 02:00.
984 1.3 christos This is the same format as the offset, except that a
985 1.22 christos leading "<code>+</code>" or "<code>-</code>" is not allowed.
986 1.1 christos </dd>
987 1.1 christos <dt><var>date</var></dt><dd>
988 1.3 christos takes one of the following forms:
989 1.1 christos <dl>
990 1.1 christos <dt>J<var>n</var> (1≤<var>n</var>≤365)</dt><dd>
991 1.3 christos origin-1 day number not counting February 29
992 1.3 christos </dd>
993 1.1 christos <dt><var>n</var> (0≤<var>n</var>≤365)</dt><dd>
994 1.3 christos origin-0 day number counting February 29 if present
995 1.3 christos </dd>
996 1.3 christos <dt><code>M</code><var>m</var><code>.</code><var>n</var><code>.</code><var>d</var>
997 1.3 christos (0[Sunday]≤<var>d</var>≤6[Saturday], 1≤<var>n</var>≤5,
998 1.3 christos 1≤<var>m</var>≤12)</dt><dd>
999 1.3 christos for the <var>d</var>th day of week <var>n</var> of
1000 1.3 christos month <var>m</var> of the year, where week 1 is the first
1001 1.3 christos week in which day <var>d</var> appears, and
1002 1.22 christos "<code>5</code>" stands for the last week in which
1003 1.3 christos day <var>d</var> appears (which may be either the 4th or
1004 1.3 christos 5th week).
1005 1.3 christos Typically, this is the only useful form; the <var>n</var>
1006 1.3 christos and <code>J</code><var>n</var> forms are rarely used.
1007 1.1 christos </dd>
1008 1.3 christos </dl>
1009 1.3 christos </dd>
1010 1.3 christos </dl>
1011 1.3 christos
1012 1.3 christos <p>
1013 1.20 christos Here is an example proleptic <code>TZ</code> string for New
1014 1.3 christos Zealand after 2007.
1015 1.3 christos It says that standard time (<abbr>NZST</abbr>) is 12 hours ahead
1016 1.3 christos of <abbr>UT</abbr>, and that daylight saving time
1017 1.22 christos (<abbr>NZDT</abbr>) is observed from Septembers last Sunday at
1018 1.22 christos 02:00 until Aprils first Sunday at 03:00:
1019 1.3 christos </p>
1020 1.3 christos
1021 1.3 christos <pre><code>TZ='NZST-12NZDT,M9.5.0,M4.1.0/3'</code></pre>
1022 1.3 christos
1023 1.3 christos <p>
1024 1.20 christos This proleptic <code>TZ</code> string is hard to remember, and
1025 1.3 christos mishandles some timestamps before 2008.
1026 1.20 christos With this package you can use a geographical <code>TZ</code> instead:
1027 1.3 christos </p>
1028 1.3 christos
1029 1.3 christos <pre><code>TZ='Pacific/Auckland'</code></pre>
1030 1.3 christos </li>
1031 1.20 christos </ul>
1032 1.20 christos
1033 1.20 christos <p>
1034 1.20 christos POSIX.1-2017 also has the limitations of POSIX.1-2024,
1035 1.20 christos discussed in the next section.
1036 1.20 christos </p>
1037 1.20 christos
1038 1.20 christos <h3 id="POSIX.1-2024">POSIX.1-2024 properties and limitations</h3>
1039 1.20 christos <p>
1040 1.20 christos POSIX.1-2024 extends POSIX.1-2017 in the following significant ways:
1041 1.20 christos </p>
1042 1.20 christos <ul>
1043 1.20 christos <li>
1044 1.20 christos POSIX.1-2024 requires support for geographical <code>TZ</code>.
1045 1.20 christos Earlier POSIX editions require support only for proleptic <code>TZ</code>.
1046 1.20 christos </li>
1047 1.20 christos <li>
1048 1.20 christos POSIX.1-2024 requires <code>struct tm</code>
1049 1.20 christos to have a <abbr>UT</abbr> offset member <code>tm_gmtoff</code>
1050 1.20 christos and a time zone abbreviation member <code>tm_zone</code>.
1051 1.20 christos Earlier POSIX editions lack this requirement.
1052 1.20 christos </li>
1053 1.3 christos <li>
1054 1.22 christos DST transition times can range from 167:59:59
1055 1.20 christos to 167:59:59 instead of merely from 00:00:00 to 24:59:59.
1056 1.20 christos This allows for proleptic TZ strings
1057 1.20 christos like <code>"<-02>2<-01>,M3.5.0/-1,M10.5.0/0"</code>
1058 1.22 christos where the transition time 1:00 means 23:00 the previous day.
1059 1.3 christos </li>
1060 1.20 christos </ul>
1061 1.20 christos <p>
1062 1.20 christos However POSIX.1-2024, like earlier POSIX editions, has some limitations:
1063 1.20 christos <ul>
1064 1.3 christos <li>
1065 1.3 christos The <code>TZ</code> environment variable is process-global, which
1066 1.3 christos makes it hard to write efficient, thread-safe applications that
1067 1.4 christos need access to multiple timezones.
1068 1.3 christos </li>
1069 1.3 christos <li>
1070 1.3 christos In POSIX, there is no tamper-proof way for a process to learn the
1071 1.22 christos systems best idea of local (wall clock) time.
1072 1.4 christos This is important for applications that an administrator wants
1073 1.22 christos used only at certain times without regard to whether the
1074 1.3 christos user has fiddled the
1075 1.3 christos <code>TZ</code> environment variable.
1076 1.22 christos While an administrator can do everything in <abbr>UT</abbr> to
1077 1.3 christos get around the problem, doing so is inconvenient and precludes
1078 1.22 christos handling daylight saving time shifts as might be required to
1079 1.4 christos limit phone calls to off-peak hours.
1080 1.3 christos </li>
1081 1.3 christos <li>
1082 1.20 christos POSIX requires that <code>time_t</code> clock counts exclude leap
1083 1.20 christos seconds.
1084 1.3 christos </li>
1085 1.3 christos <li>
1086 1.20 christos POSIX does not define the <abbr>DST</abbr> transitions
1087 1.22 christos for settings like <code>TZ='EST5EDT'</code>.
1088 1.20 christos Traditionally the current <abbr>US</abbr> <abbr>DST</abbr> rules
1089 1.20 christos were used to interpret such values, but this meant that the
1090 1.20 christos <abbr>US</abbr> <abbr>DST</abbr> rules were compiled into each
1091 1.20 christos time conversion package, and when
1092 1.20 christos <abbr>US</abbr> time conversion rules changed (as in the United
1093 1.20 christos States in 1987 and again in 2007), all packages that
1094 1.20 christos interpreted <code>TZ</code> values had to be updated
1095 1.20 christos to ensure proper results.
1096 1.3 christos </li>
1097 1.20 christos </ul>
1098 1.20 christos
1099 1.20 christos <h3 id="POSIX-extensions">Extensions to POSIX in the
1100 1.20 christos <code><abbr>tz</abbr></code> code</h3>
1101 1.20 christos <p>
1102 1.20 christos The <code><abbr>tz</abbr></code> code defines some properties
1103 1.20 christos left unspecified by POSIX, and attempts to support some
1104 1.20 christos extensions to POSIX.
1105 1.20 christos </p>
1106 1.20 christos
1107 1.20 christos <ul>
1108 1.3 christos <li>
1109 1.3 christos The <code><abbr>tz</abbr></code> code attempts to support all the
1110 1.3 christos <code>time_t</code> implementations allowed by POSIX.
1111 1.3 christos The <code>time_t</code> type represents a nonnegative count of seconds
1112 1.3 christos since 1970-01-01 00:00:00 <abbr>UTC</abbr>, ignoring leap seconds.
1113 1.3 christos In practice, <code>time_t</code> is usually a signed 64- or 32-bit
1114 1.3 christos integer; 32-bit signed <code>time_t</code> values stop working after
1115 1.3 christos 2038-01-19 03:14:07 <abbr>UTC</abbr>, so new implementations these
1116 1.3 christos days typically use a signed 64-bit integer.
1117 1.3 christos Unsigned 32-bit integers are used on one or two platforms, and 36-bit
1118 1.3 christos and 40-bit integers are also used occasionally.
1119 1.3 christos Although earlier POSIX versions allowed <code>time_t</code> to be a
1120 1.4 christos floating-point type, this was not supported by any practical system,
1121 1.20 christos and POSIX.1-2013+ and the <code><abbr>tz</abbr></code> code both
1122 1.3 christos require <code>time_t</code> to be an integer type.
1123 1.1 christos </li>
1124 1.1 christos <li>
1125 1.1 christos <p>
1126 1.20 christos If the <code>TZ</code> environment variable uses the geographical format,
1127 1.20 christos it is used in generating
1128 1.20 christos the name of a file from which time-related information is read.
1129 1.22 christos The files format is <dfn><abbr>TZif</abbr></dfn>,
1130 1.7 christos a timezone information format that contains binary data; see
1131 1.23 christos <a href="https://www.rfc-editor.org/rfc/rfc9636">Internet
1132 1.21 christos <abbr>RFC</abbr> 9636</a>.
1133 1.3 christos The daylight saving time rules to be used for a
1134 1.4 christos particular timezone are encoded in the
1135 1.4 christos <abbr>TZif</abbr> file; the format of the file allows <abbr>US</abbr>,
1136 1.4 christos Australian, and other rules to be encoded, and
1137 1.3 christos allows for situations where more than two time zone
1138 1.3 christos abbreviations are used.
1139 1.1 christos </p>
1140 1.1 christos <p>
1141 1.20 christos When the <code><abbr>tz</abbr></code> code was developed in the 1980s,
1142 1.20 christos it was recognized that allowing the <code>TZ</code> environment
1143 1.22 christos variable to take on values such as <code>America/New_York</code>
1144 1.22 christos might cause old programs (that expect <code>TZ</code> to have a
1145 1.20 christos certain format) to operate incorrectly; consideration was given to using
1146 1.3 christos some other environment variable (for example, <code>TIMEZONE</code>)
1147 1.22 christos to hold the string used to generate the <abbr>TZif</abbr> files name.
1148 1.3 christos In the end, however, it was decided to continue using
1149 1.3 christos <code>TZ</code>: it is widely used for time zone purposes;
1150 1.3 christos separately maintaining both <code>TZ</code>
1151 1.3 christos and <code>TIMEZONE</code> seemed a nuisance; and systems where
1152 1.22 christos new forms of <code>TZ</code> might cause problems can simply
1153 1.22 christos use legacy settings such as <code>TZ='EST5EDT'</code> which
1154 1.22 christos can be used by new programs as well as by old programs that
1155 1.4 christos assume pre-POSIX <code>TZ</code> values.
1156 1.1 christos </p>
1157 1.3 christos </li>
1158 1.3 christos <li>
1159 1.3 christos Functions <code>tzalloc</code>, <code>tzfree</code>,
1160 1.3 christos <code>localtime_rz</code>, and <code>mktime_z</code> for
1161 1.3 christos more-efficient thread-safe applications that need to use multiple
1162 1.4 christos timezones.
1163 1.3 christos The <code>tzalloc</code> and <code>tzfree</code> functions
1164 1.3 christos allocate and free objects of type <code>timezone_t</code>,
1165 1.3 christos and <code>localtime_rz</code> and <code>mktime_z</code> are
1166 1.3 christos like <code>localtime_r</code> and <code>mktime</code> with an
1167 1.3 christos extra <code>timezone_t</code> argument.
1168 1.20 christos The functions were inspired by <a href="https://netbsd.org">NetBSD</a>.
1169 1.3 christos </li>
1170 1.3 christos <li>
1171 1.3 christos Negative <code>time_t</code> values are supported, on systems
1172 1.3 christos where <code>time_t</code> is signed.
1173 1.3 christos </li>
1174 1.3 christos <li>
1175 1.9 christos These functions can account for leap seconds;
1176 1.9 christos see <a href="#leapsec">Leap seconds</a> below.
1177 1.3 christos </li>
1178 1.1 christos </ul>
1179 1.3 christos
1180 1.3 christos <h3 id="vestigial">POSIX features no longer needed</h3>
1181 1.1 christos <p>
1182 1.3 christos POSIX and <a href="https://en.wikipedia.org/wiki/ISO_C"><abbr>ISO</abbr> C</a>
1183 1.3 christos define some <a href="https://en.wikipedia.org/wiki/API"><abbr
1184 1.3 christos title="application programming interface">API</abbr>s</a> that are vestigial:
1185 1.3 christos they are not needed, and are relics of a too-simple model that does
1186 1.3 christos not suffice to handle many real-world timestamps.
1187 1.3 christos Although the <code><abbr>tz</abbr></code> code supports these
1188 1.3 christos vestigial <abbr>API</abbr>s for backwards compatibility, they should
1189 1.3 christos be avoided in portable applications.
1190 1.3 christos The vestigial <abbr>API</abbr>s are:
1191 1.1 christos </p>
1192 1.1 christos <ul>
1193 1.1 christos <li>
1194 1.3 christos The POSIX <code>tzname</code> variable does not suffice and is no
1195 1.3 christos longer needed.
1196 1.20 christos It is planned to be removed in a future edition of POSIX.
1197 1.22 christos To get a timestamps time zone abbreviation, consult
1198 1.3 christos the <code>tm_zone</code> member if available; otherwise,
1199 1.22 christos use <code>strftime</code>s <code>"%Z"</code> conversion
1200 1.3 christos specification.
1201 1.3 christos </li>
1202 1.3 christos <li>
1203 1.3 christos The POSIX <code>daylight</code> and <code>timezone</code>
1204 1.3 christos variables do not suffice and are no longer needed.
1205 1.20 christos They are planned to be removed in a future edition of POSIX.
1206 1.22 christos To get a timestamps <abbr>UT</abbr> offset, consult
1207 1.3 christos the <code>tm_gmtoff</code> member if available; otherwise,
1208 1.3 christos subtract values returned by <code>localtime</code>
1209 1.3 christos and <code>gmtime</code> using the rules of the Gregorian calendar,
1210 1.22 christos or use <code>strftime</code>s <code>"%z"</code> conversion
1211 1.3 christos specification if a string like <code>"+0900"</code> suffices.
1212 1.3 christos </li>
1213 1.3 christos <li>
1214 1.3 christos The <code>tm_isdst</code> member is almost never needed and most of
1215 1.3 christos its uses should be discouraged in favor of the abovementioned
1216 1.3 christos <abbr>API</abbr>s.
1217 1.21 christos It was intended as an index into the <code>tzname</code> variable,
1218 1.21 christos but as mentioned previously that usage is obsolete.
1219 1.3 christos Although it can still be used in arguments to
1220 1.3 christos <code>mktime</code> to disambiguate timestamps near
1221 1.15 christos a <abbr>DST</abbr> transition when the clock jumps back on
1222 1.15 christos platforms lacking <code>tm_gmtoff</code>, this
1223 1.21 christos disambiguation works only for proleptic <code>TZ</code> strings;
1224 1.21 christos it does not work in general for geographical timezones,
1225 1.21 christos such as when a location changes to a time zone with a
1226 1.3 christos lesser <abbr>UT</abbr> offset.
1227 1.3 christos </li>
1228 1.3 christos </ul>
1229 1.3 christos
1230 1.3 christos <h3 id="other-portability">Other portability notes</h3>
1231 1.3 christos <ul>
1232 1.3 christos <li>
1233 1.3 christos The <a href="https://en.wikipedia.org/wiki/Version_7_Unix">7th Edition
1234 1.3 christos UNIX</a> <code>timezone</code> function is not present in this
1235 1.22 christos package; it is impossible to reliably map <code>timezone</code>s
1236 1.22 christos arguments (a minutes west of <abbr>GMT</abbr> value and a
1237 1.22 christos daylight saving time in effect flag) to a time zone
1238 1.3 christos abbreviation, and we refuse to guess.
1239 1.3 christos Programs that in the past used the <code>timezone</code> function
1240 1.3 christos may now examine <code>localtime(&clock)->tm_zone</code>
1241 1.3 christos (if <code>TM_ZONE</code> is defined) or
1242 1.21 christos use <code>strftime</code> with a <code>%Z</code> conversion specification
1243 1.21 christos to learn the correct time
1244 1.3 christos zone abbreviation to use.
1245 1.3 christos </li>
1246 1.3 christos <li>
1247 1.3 christos The <a
1248 1.3 christos href="https://en.wikipedia.org/wiki/History_of_the_Berkeley_Software_Distribution#4.2BSD"><abbr>4.2BSD</abbr></a>
1249 1.3 christos <code>gettimeofday</code> function is not
1250 1.3 christos used in this package.
1251 1.3 christos This formerly let users obtain the current <abbr>UTC</abbr> offset
1252 1.3 christos and <abbr>DST</abbr> flag, but this functionality was removed in
1253 1.3 christos later versions of <abbr>BSD</abbr>.
1254 1.3 christos </li>
1255 1.3 christos <li>
1256 1.3 christos In <abbr>SVR2</abbr>, time conversion fails for near-minimum or
1257 1.3 christos near-maximum <code>time_t</code> values when doing conversions
1258 1.3 christos for places that do not use <abbr>UT</abbr>.
1259 1.3 christos This package takes care to do these conversions correctly.
1260 1.3 christos A comment in the source code tells how to get compatibly wrong
1261 1.3 christos results.
1262 1.3 christos </li>
1263 1.3 christos <li>
1264 1.3 christos The functions that are conditionally compiled
1265 1.18 christos if <code>STD_INSPIRED</code> is nonzero should, at this point, be
1266 1.3 christos looked on primarily as food for thought.
1267 1.22 christos They are not in any sense standard compatible some are
1268 1.3 christos not, in fact, specified in <em>any</em> standard.
1269 1.3 christos They do, however, represent responses of various authors to
1270 1.3 christos standardization proposals.
1271 1.3 christos </li>
1272 1.3 christos <li>
1273 1.4 christos Other time conversion proposals, in particular those supported by the
1274 1.4 christos <a href="https://howardhinnant.github.io/date/tz.html">Time Zone
1275 1.4 christos Database Parser</a>, offer a wider selection of functions
1276 1.3 christos that provide capabilities beyond those provided here.
1277 1.3 christos The absence of such functions from this package is not meant to
1278 1.3 christos discourage the development, standardization, or use of such
1279 1.3 christos functions.
1280 1.3 christos Rather, their absence reflects the decision to make this package
1281 1.3 christos contain valid extensions to POSIX, to ensure its broad
1282 1.3 christos acceptability.
1283 1.3 christos If more powerful time conversion functions can be standardized, so
1284 1.3 christos much the better.
1285 1.1 christos </li>
1286 1.1 christos </ul>
1287 1.3 christos </section>
1288 1.1 christos
1289 1.3 christos <section>
1290 1.3 christos <h2 id="stability">Interface stability</h2>
1291 1.1 christos <p>
1292 1.3 christos The <code><abbr>tz</abbr></code> code and data supply the following interfaces:
1293 1.1 christos </p>
1294 1.1 christos
1295 1.1 christos <ul>
1296 1.1 christos <li>
1297 1.4 christos A set of timezone names as per
1298 1.22 christos <a href="#naming">Timezone identifiers</a> above.
1299 1.1 christos </li>
1300 1.1 christos <li>
1301 1.22 christos Library functions described in <a href="#functions">Time and date
1302 1.22 christos functions</a> above.
1303 1.1 christos </li>
1304 1.1 christos <li>
1305 1.3 christos The programs <code>tzselect</code>, <code>zdump</code>,
1306 1.3 christos and <code>zic</code>, documented in their man pages.
1307 1.1 christos </li>
1308 1.1 christos <li>
1309 1.3 christos The format of <code>zic</code> input files, documented in
1310 1.3 christos the <code>zic</code> man page.
1311 1.1 christos </li>
1312 1.1 christos <li>
1313 1.3 christos The format of <code>zic</code> output files, documented in
1314 1.3 christos the <code>tzfile</code> man page.
1315 1.1 christos </li>
1316 1.1 christos <li>
1317 1.3 christos The format of zone table files, documented in <code>zone1970.tab</code>.
1318 1.1 christos </li>
1319 1.1 christos <li>
1320 1.3 christos The format of the country code file, documented in <code>iso3166.tab</code>.
1321 1.1 christos </li>
1322 1.1 christos <li>
1323 1.3 christos The version number of the code and data, as the first line of
1324 1.22 christos the text file "<code>version</code>" in each release.
1325 1.1 christos </li>
1326 1.1 christos </ul>
1327 1.3 christos
1328 1.1 christos <p>
1329 1.1 christos Interface changes in a release attempt to preserve compatibility with
1330 1.3 christos recent releases.
1331 1.3 christos For example, <code><abbr>tz</abbr></code> data files typically do not
1332 1.18 christos rely on recently added <code>zic</code> features, so that users can
1333 1.3 christos run older <code>zic</code> versions to process newer data files.
1334 1.3 christos <a href="tz-link.html#download">Downloading
1335 1.3 christos the <code><abbr>tz</abbr></code> database</a> describes how releases
1336 1.3 christos are tagged and distributed.
1337 1.1 christos </p>
1338 1.1 christos
1339 1.1 christos <p>
1340 1.3 christos Interfaces not listed above are less stable.
1341 1.3 christos For example, users should not rely on particular <abbr>UT</abbr>
1342 1.3 christos offsets or abbreviations for timestamps, as data entries are often
1343 1.3 christos based on guesswork and these guesses may be corrected or improved.
1344 1.1 christos </p>
1345 1.7 christos
1346 1.7 christos <p>
1347 1.7 christos Timezone boundaries are not part of the stable interface.
1348 1.7 christos For example, even though the <samp>Asia/Bangkok</samp> timezone
1349 1.7 christos currently includes Chang Mai, Hanoi, and Phnom Penh, this is not part
1350 1.7 christos of the stable interface and the timezone can split at any time.
1351 1.7 christos If a calendar application records a future event in some location other
1352 1.22 christos than Bangkok by putting <samp>Asia/Bangkok</samp> in the events record,
1353 1.7 christos the application should be robust in the presence of timezone splits
1354 1.7 christos between now and the future time.
1355 1.7 christos </p>
1356 1.3 christos </section>
1357 1.1 christos
1358 1.3 christos <section>
1359 1.9 christos <h2 id="leapsec">Leap seconds</h2>
1360 1.9 christos <p>
1361 1.18 christos Leap seconds were introduced in 1972 to accommodate the
1362 1.18 christos difference between atomic time and the less regular rotation of the earth.
1363 1.20 christos Unfortunately they have caused so many problems with civil
1364 1.20 christos timekeeping that there are
1365 1.20 christos <a href="https://www.bipm.org/en/cgpm-2022/resolution-4">plans
1366 1.20 christos to discontinue them by 2035</a>.
1367 1.20 christos Even if these plans come to fruition, a record of leap seconds will still be
1368 1.20 christos needed to resolve timestamps from 1972 through 2035,
1369 1.20 christos and there may also be a need to record whatever mechanism replaces them.
1370 1.18 christos </p>
1371 1.18 christos
1372 1.18 christos <p>
1373 1.9 christos The <code><abbr>tz</abbr></code> code and data can account for leap seconds,
1374 1.9 christos thanks to code contributed by Bradley White.
1375 1.9 christos However, the leap second support of this package is rarely used directly
1376 1.9 christos because POSIX requires leap seconds to be excluded and many
1377 1.9 christos software packages would mishandle leap seconds if they were present.
1378 1.9 christos Instead, leap seconds are more commonly handled by occasionally adjusting
1379 1.9 christos the operating system kernel clock as described in
1380 1.9 christos <a href="tz-link.html#precision">Precision timekeeping</a>,
1381 1.9 christos and this package by default installs a <samp>leapseconds</samp> file
1382 1.9 christos commonly used by
1383 1.15 christos <a href="https://www.ntp.org"><abbr title="Network Time Protocol">NTP</abbr></a>
1384 1.9 christos software that adjusts the kernel clock.
1385 1.9 christos However, kernel-clock twiddling approximates UTC only roughly,
1386 1.22 christos and systems needing more precise UTC can use this packages leap
1387 1.9 christos second support directly.
1388 1.9 christos </p>
1389 1.9 christos
1390 1.9 christos <p>
1391 1.18 christos The directly supported mechanism assumes that <code>time_t</code>
1392 1.9 christos counts of seconds since the POSIX epoch normally include leap seconds,
1393 1.9 christos as opposed to POSIX <code>time_t</code> counts which exclude leap seconds.
1394 1.9 christos This modified timescale is converted to <abbr>UTC</abbr>
1395 1.12 christos at the same point that time zone and <abbr>DST</abbr>
1396 1.22 christos adjustments are applied
1397 1.22 christos namely, at calls to <code>localtime</code> and analogous functions
1398 1.9 christos and the process is driven by leap second information
1399 1.9 christos stored in alternate versions of the <abbr>TZif</abbr> files.
1400 1.9 christos Because a leap second adjustment may be needed even
1401 1.9 christos if no time zone correction is desired,
1402 1.9 christos calls to <code>gmtime</code>-like functions
1403 1.9 christos also need to consult a <abbr>TZif</abbr> file,
1404 1.14 christos conventionally named <samp><abbr>Etc/UTC</abbr></samp>
1405 1.14 christos (<samp><abbr>GMT</abbr></samp> in previous versions),
1406 1.9 christos to see whether leap second corrections are needed.
1407 1.22 christos To convert an applications <code>time_t</code> timestamps to or from
1408 1.9 christos POSIX <code>time_t</code> timestamps (for use when, say,
1409 1.9 christos embedding or interpreting timestamps in portable
1410 1.9 christos <a href="https://en.wikipedia.org/wiki/Tar_(computing)"><code>tar</code></a>
1411 1.9 christos files),
1412 1.9 christos the application can call the utility functions
1413 1.9 christos <code>time2posix</code> and <code>posix2time</code>
1414 1.9 christos included with this package.
1415 1.9 christos </p>
1416 1.9 christos
1417 1.9 christos <p>
1418 1.9 christos If the POSIX-compatible <abbr>TZif</abbr> file set is installed
1419 1.9 christos in a directory whose basename is <samp>zoneinfo</samp>, the
1420 1.9 christos leap-second-aware file set is by default installed in a separate
1421 1.9 christos directory <samp>zoneinfo-leaps</samp>.
1422 1.9 christos Although each process can have its own time zone by setting
1423 1.9 christos its <code>TZ</code> environment variable, there is no support for some
1424 1.9 christos processes being leap-second aware while other processes are
1425 1.9 christos POSIX-compatible; the leap-second choice is system-wide.
1426 1.9 christos So if you configure your kernel to count leap seconds, you should also
1427 1.9 christos discard <samp>zoneinfo</samp> and rename <samp>zoneinfo-leaps</samp>
1428 1.9 christos to <samp>zoneinfo</samp>.
1429 1.9 christos Alternatively, you can install just one set of <abbr>TZif</abbr> files
1430 1.22 christos in the first place; see the <code>REDO</code> variable in this packages
1431 1.9 christos <a href="https://en.wikipedia.org/wiki/Makefile">makefile</a>.
1432 1.9 christos </p>
1433 1.9 christos </section>
1434 1.9 christos
1435 1.9 christos <section>
1436 1.3 christos <h2 id="calendar">Calendrical issues</h2>
1437 1.1 christos <p>
1438 1.1 christos Calendrical issues are a bit out of scope for a time zone database,
1439 1.1 christos but they indicate the sort of problems that we would run into if we
1440 1.3 christos extended the time zone database further into the past.
1441 1.3 christos An excellent resource in this area is Edward M. Reingold
1442 1.3 christos and Nachum Dershowitz, <cite><a
1443 1.23 christos href="https://www.cambridge.org/fr/universitypress/subjects/computer-science/computing-general-interest/calendrical-calculations-ultimate-edition-4th-edition">Calendrical
1444 1.3 christos Calculations: The Ultimate Edition</a></cite>, Cambridge University Press (2018).
1445 1.22 christos Other information and sources are given in the file "<code>calendars</code>"
1446 1.3 christos in the <code><abbr>tz</abbr></code> distribution.
1447 1.3 christos They sometimes disagree.
1448 1.3 christos </p>
1449 1.3 christos </section>
1450 1.3 christos
1451 1.3 christos <section>
1452 1.18 christos <h2 id="planets">Time and time zones off Earth</h2>
1453 1.18 christos <p>
1454 1.18 christos The European Space Agency is <a
1455 1.23 christos href="https://www.esa.int/Applications/Satellite_navigation/Telling_time_on_the_Moon">considering</a>
1456 1.18 christos the establishment of a reference timescale for the Moon, which has
1457 1.18 christos days roughly equivalent to 29.5 Earth days, and where relativistic
1458 1.18 christos effects cause clocks to tick slightly faster than on Earth.
1459 1.20 christos Also, <abbr title="National Aeronautics and Space Administration">NASA</abbr>
1460 1.20 christos has been <a
1461 1.23 christos href="https://bidenwhitehouse.archives.gov/wp-content/uploads/2024/04/Celestial-Time-Standardization-Policy.pdf">ordered</a>
1462 1.20 christos to consider the establishment of Coordinated Lunar Time (<abbr>LTC</abbr>).
1463 1.20 christos It is not yet known whether the US and European efforts will result in
1464 1.20 christos multiple timescales on the Moon.
1465 1.18 christos </p>
1466 1.18 christos
1467 1.3 christos <p>
1468 1.22 christos Some peoples work schedules have used
1469 1.10 christos <a href="https://en.wikipedia.org/wiki/Timekeeping_on_Mars">Mars time</a>.
1470 1.3 christos Jet Propulsion Laboratory (JPL) coordinators kept Mars time on
1471 1.3 christos and off during the
1472 1.6 christos <a href="https://en.wikipedia.org/wiki/Mars_Pathfinder">Mars
1473 1.10 christos Pathfinder</a> mission (1997).
1474 1.3 christos Some of their family members also adapted to Mars time.
1475 1.3 christos Dozens of special Mars watches were built for JPL workers who kept
1476 1.10 christos Mars time during the
1477 1.10 christos <a href="https://en.wikipedia.org/wiki/Mars_Exploration_Rover">Mars
1478 1.22 christos Exploration Rovers (MER)</a> mission (20042018).
1479 1.10 christos These timepieces looked like normal Seikos and Citizens but were adjusted
1480 1.10 christos to use Mars seconds rather than terrestrial seconds, although
1481 1.10 christos unfortunately the adjusted watches were unreliable and appear to have
1482 1.10 christos had only limited use.
1483 1.1 christos </p>
1484 1.1 christos
1485 1.1 christos <p>
1486 1.22 christos A Mars solar day is called a sol and has a mean period equal to
1487 1.3 christos about 24 hours 39 minutes 35.244 seconds in terrestrial time.
1488 1.3 christos It is divided into a conventional 24-hour clock, so each Mars second
1489 1.3 christos equals about 1.02749125 terrestrial seconds.
1490 1.22 christos (One MER worker noted, If I am working Mars hours, and Mars hours are
1491 1.22 christos 2.5% more than Earth hours, shouldnt I get an extra 2.5% pay raise?)
1492 1.1 christos </p>
1493 1.1 christos
1494 1.1 christos <p>
1495 1.3 christos The <a href="https://en.wikipedia.org/wiki/Prime_meridian">prime
1496 1.3 christos meridian</a> of Mars goes through the center of the crater
1497 1.3 christos <a href="https://en.wikipedia.org/wiki/Airy-0">Airy-0</a>, named in
1498 1.3 christos honor of the British astronomer who built the Greenwich telescope that
1499 1.22 christos defines Earths prime meridian.
1500 1.3 christos Mean solar time on the Mars prime meridian is
1501 1.6 christos called Mars Coordinated Time (<abbr>MTC</abbr>).
1502 1.1 christos </p>
1503 1.1 christos
1504 1.1 christos <p>
1505 1.1 christos Each landed mission on Mars has adopted a different reference for
1506 1.4 christos solar timekeeping, so there is no real standard for Mars time zones.
1507 1.22 christos For example, the MER mission defined two time zones Local
1508 1.22 christos Solar Time A and Local Solar Time B for its two missions, each zone
1509 1.3 christos designed so that its time equals local true solar time at
1510 1.3 christos approximately the middle of the nominal mission.
1511 1.10 christos The A and B zones differ enough so that an MER worker assigned to
1512 1.22 christos the A zone might suffer Mars lag when switching to work in the B zone.
1513 1.22 christos Such a time zone is not particularly suited for any application
1514 1.3 christos other than the mission itself.
1515 1.1 christos </p>
1516 1.1 christos
1517 1.1 christos <p>
1518 1.1 christos Many calendars have been proposed for Mars, but none have achieved
1519 1.3 christos wide acceptance.
1520 1.3 christos Astronomers often use Mars Sol Date (<abbr>MSD</abbr>) which is a
1521 1.1 christos sequential count of Mars solar days elapsed since about 1873-12-29
1522 1.3 christos 12:00 <abbr>GMT</abbr>.
1523 1.1 christos </p>
1524 1.1 christos
1525 1.1 christos <p>
1526 1.1 christos In our solar system, Mars is the planet with time and calendar most
1527 1.22 christos like Earths.
1528 1.3 christos On other planets, Sun-based time and calendars would work quite
1529 1.3 christos differently.
1530 1.22 christos For example, although Mercurys
1531 1.3 christos <a href="https://en.wikipedia.org/wiki/Rotation_period">sidereal
1532 1.3 christos rotation period</a> is 58.646 Earth days, Mercury revolves around the
1533 1.22 christos Sun so rapidly that an observer on Mercurys equator would see a
1534 1.3 christos sunrise only every 175.97 Earth days, i.e., a Mercury year is 0.5 of a
1535 1.3 christos Mercury day.
1536 1.3 christos Venus is more complicated, partly because its rotation is slightly
1537 1.3 christos <a href="https://en.wikipedia.org/wiki/Retrograde_motion">retrograde</a>:
1538 1.3 christos its year is 1.92 of its days.
1539 1.3 christos Gas giants like Jupiter are trickier still, as their polar and
1540 1.3 christos equatorial regions rotate at different rates, so that the length of a
1541 1.3 christos day depends on latitude.
1542 1.3 christos This effect is most pronounced on Neptune, where the day is about 12
1543 1.3 christos hours at the poles and 18 hours at the equator.
1544 1.1 christos </p>
1545 1.1 christos
1546 1.1 christos <p>
1547 1.3 christos Although the <code><abbr>tz</abbr></code> database does not support
1548 1.3 christos time on other planets, it is documented here in the hopes that support
1549 1.3 christos will be added eventually.
1550 1.1 christos </p>
1551 1.1 christos
1552 1.1 christos <p>
1553 1.3 christos Sources for time on other planets:
1554 1.1 christos </p>
1555 1.3 christos
1556 1.1 christos <ul>
1557 1.1 christos <li>
1558 1.3 christos Michael Allison and Robert Schmunk,
1559 1.22 christos <a href="https://www.giss.nasa.gov/tools/mars24/help/notes.html">Technical
1560 1.22 christos Notes on Mars Solar Time as Adopted by the Mars24 Sunclock</a>
1561 1.10 christos (2020-03-08).
1562 1.10 christos </li>
1563 1.10 christos <li>
1564 1.10 christos Zara Mirmalek,
1565 1.10 christos <em><a href="https://mitpress.mit.edu/books/making-time-mars">Making
1566 1.10 christos Time on Mars</a></em>, MIT Press (March 2020), ISBN 978-0262043854.
1567 1.1 christos </li>
1568 1.1 christos <li>
1569 1.3 christos Jia-Rui Chong,
1570 1.22 christos <a href="https://www.latimes.com/archives/la-xpm-2004-jan-14-sci-marstime14-story.html">Workdays
1571 1.22 christos Fit for a Martian</a>, <cite>Los Angeles Times</cite>
1572 1.22 christos (2004-01-14), pp A1, A20A21.
1573 1.1 christos </li>
1574 1.1 christos <li>
1575 1.3 christos Tom Chmielewski,
1576 1.22 christos <a href="https://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/">Jet
1577 1.22 christos Lag Is Worse on Mars</a>, <cite>The Atlantic</cite> (2015-02-26)
1578 1.1 christos </li>
1579 1.1 christos <li>
1580 1.3 christos Matt Williams,
1581 1.23 christos <a href="https://www.universetoday.com/articles/days-of-the-planets">How
1582 1.22 christos long is a day on the other planets of the solar system?</a>
1583 1.4 christos (2016-01-20).
1584 1.1 christos </li>
1585 1.1 christos </ul>
1586 1.3 christos </section>
1587 1.1 christos
1588 1.3 christos <footer>
1589 1.22 christos <hr>
1590 1.22 christos This web page is in the public domain, so clarified as of
1591 1.22 christos 2009-05-17 by Arthur David Olson.
1592 1.22 christos <br>
1593 1.22 christos Please send corrections to this web page to the
1594 1.22 christos <a href="mailto:tz (a] iana.org">time zone mailing list</a>.
1595 1.22 christos The mailing list and its archives are public,
1596 1.22 christos so please do not send confidential information.
1597 1.3 christos </footer>
1598 1.1 christos </body>
1599 1.1 christos </html>
1600