Deleted Added
full compact
theory.html (331663) theory.html (333313)
1<html lang="en">
2<head>
3 <title>Theory and pragmatics of the tz code and data</title>
4 <meta charset="UTF-8">
5</head>
6
7<body>
8<h1>Theory and pragmatics of the <code><abbr>tz</abbr></code> code and data</h1>

--- 18 unchanged lines hidden (view full) ---

27<p>
28The <a
29href="https://www.iana.org/time-zones"><code><abbr>tz</abbr></code>
30database</a> attempts to record the history and predicted future of
31all computer-based clocks that track civil time.
32It organizes <a href="tz-link.html">time zone and daylight saving time
33data</a> by partitioning the world into <a
34href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">regions</a>
1<html lang="en">
2<head>
3 <title>Theory and pragmatics of the tz code and data</title>
4 <meta charset="UTF-8">
5</head>
6
7<body>
8<h1>Theory and pragmatics of the <code><abbr>tz</abbr></code> code and data</h1>

--- 18 unchanged lines hidden (view full) ---

27<p>
28The <a
29href="https://www.iana.org/time-zones"><code><abbr>tz</abbr></code>
30database</a> attempts to record the history and predicted future of
31all computer-based clocks that track civil time.
32It organizes <a href="tz-link.html">time zone and daylight saving time
33data</a> by partitioning the world into <a
34href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">regions</a>
35whose clocks all agree about timestamps that occur after the of the <a
35whose clocks all agree about timestamps that occur after the
36href="https://en.wikipedia.org/wiki/Unix_time">POSIX Epoch</a>
37(1970-01-01 00:00:00 <a
38href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time"><abbr
39title="Coordinated Universal Time">UTC</abbr></a>).
40The database labels each such region with a notable location and
41records all known clock transitions for that location.
42Although 1970 is a somewhat-arbitrary cutoff, there are significant
43challenges to moving the cutoff earlier even by a decade or two, due

--- 4 unchanged lines hidden (view full) ---

48<p>
49Clock transitions before 1970 are recorded for each such location,
50because most systems support timestamps before 1970 and could
51misbehave if data entries were omitted for pre-1970 transitions.
52However, the database is not designed for and does not suffice for
53applications requiring accurate handling of all past times everywhere,
54as it would take far too much effort and guesswork to record all
55details of pre-1970 civil timekeeping.
36href="https://en.wikipedia.org/wiki/Unix_time">POSIX Epoch</a>
37(1970-01-01 00:00:00 <a
38href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time"><abbr
39title="Coordinated Universal Time">UTC</abbr></a>).
40The database labels each such region with a notable location and
41records all known clock transitions for that location.
42Although 1970 is a somewhat-arbitrary cutoff, there are significant
43challenges to moving the cutoff earlier even by a decade or two, due

--- 4 unchanged lines hidden (view full) ---

48<p>
49Clock transitions before 1970 are recorded for each such location,
50because most systems support timestamps before 1970 and could
51misbehave if data entries were omitted for pre-1970 transitions.
52However, the database is not designed for and does not suffice for
53applications requiring accurate handling of all past times everywhere,
54as it would take far too much effort and guesswork to record all
55details of pre-1970 civil timekeeping.
56Athough some information outside the scope of the database is
56Although some information outside the scope of the database is
57collected in a file <code>backzone</code> that is distributed along
58with the database proper, this file is less reliable and does not
59necessarily follow database guidelines.
60</p>
61
62<p>
63As described below, reference source code for using the
64<code><abbr>tz</abbr></code> database is also available.
65The <code><abbr>tz</abbr></code> code is upwards compatible with <a
66href="https://en.wikipedia.org/wiki/POSIX">POSIX</a>, an international
67standard for <a
68href="https://en.wikipedia.org/wiki/Unix">UNIX</a>-like systems.
69As of this writing, the current edition of POSIX is: <a
70href="http://pubs.opengroup.org/onlinepubs/9699919799/"> The Open
57collected in a file <code>backzone</code> that is distributed along
58with the database proper, this file is less reliable and does not
59necessarily follow database guidelines.
60</p>
61
62<p>
63As described below, reference source code for using the
64<code><abbr>tz</abbr></code> database is also available.
65The <code><abbr>tz</abbr></code> code is upwards compatible with <a
66href="https://en.wikipedia.org/wiki/POSIX">POSIX</a>, an international
67standard for <a
68href="https://en.wikipedia.org/wiki/Unix">UNIX</a>-like systems.
69As of this writing, the current edition of POSIX is: <a
70href="http://pubs.opengroup.org/onlinepubs/9699919799/"> The Open
71Group Base Specifications Issue 7</a>, IEEE Std 1003.1-2008, 2016
71Group Base Specifications Issue 7</a>, IEEE Std 1003.1-2017, 2018
72Edition.
73Because the database's scope encompasses real-world changes to civil
74timekeeping, its model for describing time is more complex than the
75standard and daylight saving times supported by POSIX.
76A <code><abbr>tz</abbr></code> region corresponds to a ruleset that can
77have more than two changes per year, these changes need not merely
78flip back and forth between two alternatives, and the rules themselves
79can change at times.
80Whether and when a <code><abbr>tz</abbr></code> region changes its
81clock, and even the region's notional base offset from UTC, are variable.
72Edition.
73Because the database's scope encompasses real-world changes to civil
74timekeeping, its model for describing time is more complex than the
75standard and daylight saving times supported by POSIX.
76A <code><abbr>tz</abbr></code> region corresponds to a ruleset that can
77have more than two changes per year, these changes need not merely
78flip back and forth between two alternatives, and the rules themselves
79can change at times.
80Whether and when a <code><abbr>tz</abbr></code> region changes its
81clock, and even the region's notional base offset from UTC, are variable.
82It doesn't even really make sense to talk about a region's
82It does not always make sense to talk about a region's
83"base offset", since it is not necessarily a single number.
84</p>
85
86</section>
87
88<section>
89 <h2 id="naming">Names of time zone rulesets</h2>
90<p>
91Each <code><abbr>tz</abbr></code> region has a unique name that
92corresponds to a set of time zone rules.
93Inexperienced users are not expected to select these names unaided.
94Distributors should provide documentation and/or a simple selection
83"base offset", since it is not necessarily a single number.
84</p>
85
86</section>
87
88<section>
89 <h2 id="naming">Names of time zone rulesets</h2>
90<p>
91Each <code><abbr>tz</abbr></code> region has a unique name that
92corresponds to a set of time zone rules.
93Inexperienced users are not expected to select these names unaided.
94Distributors should provide documentation and/or a simple selection
95interface that explains the names; for one example, see the 'tzselect'
96program in the tz code.
95interface that explains the names; for one example, see the
96<code>tzselect</code> program in the <code><abbr>tz</abbr></code> code.
97The <a href="http://cldr.unicode.org/">Unicode Common Locale Data
98Repository</a> contains data that may be useful for other selection
99interfaces.
100</p>
101
102<p>
103The naming conventions attempt to strike a balance
104among the following goals:

--- 27 unchanged lines hidden (view full) ---

132Names normally have the form
133<var>AREA</var><code>/</code><var>LOCATION</var>, where
134<var>AREA</var> is the name of a continent or ocean, and
135<var>LOCATION</var> is the name of a specific location within that
136region.
137North and South America share the same area, '<code>America</code>'.
138Typical names are '<code>Africa/Cairo</code>',
139'<code>America/New_York</code>', and '<code>Pacific/Honolulu</code>'.
97The <a href="http://cldr.unicode.org/">Unicode Common Locale Data
98Repository</a> contains data that may be useful for other selection
99interfaces.
100</p>
101
102<p>
103The naming conventions attempt to strike a balance
104among the following goals:

--- 27 unchanged lines hidden (view full) ---

132Names normally have the form
133<var>AREA</var><code>/</code><var>LOCATION</var>, where
134<var>AREA</var> is the name of a continent or ocean, and
135<var>LOCATION</var> is the name of a specific location within that
136region.
137North and South America share the same area, '<code>America</code>'.
138Typical names are '<code>Africa/Cairo</code>',
139'<code>America/New_York</code>', and '<code>Pacific/Honolulu</code>'.
140Some names are further qualified to help avoid confusion; for example,
141'<code>America/Indiana/Petersburg</code>' distinguishes Petersburg,
142Indiana from other Petersburgs in America.
140</p>
141
142<p>
143Here are the general guidelines used for
144choosing <code><abbr>tz</abbr></code> region names,
145in decreasing order of importance:
146</p>
147

--- 6 unchanged lines hidden (view full) ---

154 Within a file name component, use only <a
155 href="https://en.wikipedia.org/wiki/ASCII">ASCII</a> letters,
156 '<code>.</code>', '<code>-</code>' and '<code>_</code>'.
157 Do not use digits, as that might create an ambiguity with <a
158 href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03">POSIX
159 <code>TZ</code> strings</a>.
160 A file name component must not exceed 14 characters or start with
161 '<code>-</code>'.
143</p>
144
145<p>
146Here are the general guidelines used for
147choosing <code><abbr>tz</abbr></code> region names,
148in decreasing order of importance:
149</p>
150

--- 6 unchanged lines hidden (view full) ---

157 Within a file name component, use only <a
158 href="https://en.wikipedia.org/wiki/ASCII">ASCII</a> letters,
159 '<code>.</code>', '<code>-</code>' and '<code>_</code>'.
160 Do not use digits, as that might create an ambiguity with <a
161 href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03">POSIX
162 <code>TZ</code> strings</a>.
163 A file name component must not exceed 14 characters or start with
164 '<code>-</code>'.
162 E.g., prefer '<code>Brunei</code>' to '<code>Bandar_Seri_Begawan</code>'.
165 E.g., prefer <code>Asia/Brunei</code> to
166 <code>Asia/Bandar_Seri_Begawan</code>.
163 Exceptions: see the discussion of legacy names below.
164 </li>
165 <li>
166 A name must not be empty, or contain '<code>//</code>', or
167 start or end with '<code>/</code>'.
168 </li>
169 <li>
170 Do not use names that differ only in case.
171 Although the reference implementation is case-sensitive, some
172 other implementations are not, and they would mishandle names
173 differing only in case.
174 </li>
175 <li>
176 If one name <var>A</var> is an initial prefix of another
177 name <var>AB</var> (ignoring case), then <var>B</var> must not
178 start with '<code>/</code>', as a regular file cannot have the
179 same name as a directory in POSIX.
167 Exceptions: see the discussion of legacy names below.
168 </li>
169 <li>
170 A name must not be empty, or contain '<code>//</code>', or
171 start or end with '<code>/</code>'.
172 </li>
173 <li>
174 Do not use names that differ only in case.
175 Although the reference implementation is case-sensitive, some
176 other implementations are not, and they would mishandle names
177 differing only in case.
178 </li>
179 <li>
180 If one name <var>A</var> is an initial prefix of another
181 name <var>AB</var> (ignoring case), then <var>B</var> must not
182 start with '<code>/</code>', as a regular file cannot have the
183 same name as a directory in POSIX.
180 For example, '<code>America/New_York</code>' precludes
181 '<code>America/New_York/Bronx</code>'.
184 For example, <code>America/New_York</code> precludes
185 <code>America/New_York/Bronx</code>.
182 </li>
183 <li>
184 Uninhabited regions like the North Pole and Bouvet Island
185 do not need locations, since local time is not defined there.
186 </li>
187 <li>
188 There should typically be at least one name for each <a
189 href="https://en.wikipedia.org/wiki/ISO_3166-1"><abbr
190 title="International Organization for Standardization">ISO</abbr>
191 3166-1</a> officially assigned two-letter code for an inhabited
192 country or territory.
193 </li>
194 <li>
195 If all the clocks in a region have agreed since 1970,
186 </li>
187 <li>
188 Uninhabited regions like the North Pole and Bouvet Island
189 do not need locations, since local time is not defined there.
190 </li>
191 <li>
192 There should typically be at least one name for each <a
193 href="https://en.wikipedia.org/wiki/ISO_3166-1"><abbr
194 title="International Organization for Standardization">ISO</abbr>
195 3166-1</a> officially assigned two-letter code for an inhabited
196 country or territory.
197 </li>
198 <li>
199 If all the clocks in a region have agreed since 1970,
196 don't bother to include more than one location
200 do not bother to include more than one location
197 even if subregions' clocks disagreed before 1970.
198 Otherwise these tables would become annoyingly large.
199 </li>
200 <li>
201 If a name is ambiguous, use a less ambiguous alternative;
202 e.g., many cities are named San Jos�� and Georgetown, so
201 even if subregions' clocks disagreed before 1970.
202 Otherwise these tables would become annoyingly large.
203 </li>
204 <li>
205 If a name is ambiguous, use a less ambiguous alternative;
206 e.g., many cities are named San Jos�� and Georgetown, so
203 prefer '<code>Costa_Rica</code>' to '<code>San_Jose</code>' and
204 '<code>Guyana</code>' to '<code>Georgetown</code>'.
207 prefer <code>America/Costa_Rica</code> to
208 <code>America/San_Jose</code> and <code>America/Guyana</code>
209 to <code>America/Georgetown</code>.
205 </li>
206 <li>
207 Keep locations compact.
208 Use cities or small islands, not countries or regions, so that any
209 future changes do not split individual locations into different
210 <code><abbr>tz</abbr></code> regions.
210 </li>
211 <li>
212 Keep locations compact.
213 Use cities or small islands, not countries or regions, so that any
214 future changes do not split individual locations into different
215 <code><abbr>tz</abbr></code> regions.
211 E.g., prefer '<code>Paris</code>' to '<code>France</code>', since
216 E.g., prefer <code>Europe/Paris</code> to <code>Europe/France</code>,
217 since
212 <a href="https://en.wikipedia.org/wiki/Time_in_France#History">France
213 has had multiple time zones</a>.
214 </li>
215 <li>
218 <a href="https://en.wikipedia.org/wiki/Time_in_France#History">France
219 has had multiple time zones</a>.
220 </li>
221 <li>
216 Use mainstream English spelling, e.g., prefer '<code>Rome</code>'
217 to '<code>Roma</code>', and prefer '<code>Athens</code>' to the
218 Greek '<code>����������</code>' or the Romanized '<code>Ath��na</code>'.
222 Use mainstream English spelling, e.g., prefer
223 <code>Europe/Rome</code> to <code>Europe/Roma</code>, and
224 prefer <code>Europe/Athens</code> to the Greek
225 <code>Europe/����������</code> or the Romanized
226 <code>Europe/Ath��na</code>.
219 The POSIX file name restrictions encourage this guideline.
220 </li>
221 <li>
222 Use the most populous among locations in a region,
227 The POSIX file name restrictions encourage this guideline.
228 </li>
229 <li>
230 Use the most populous among locations in a region,
223 e.g., prefer '<code>Shanghai</code>' to
224 '<code>Beijing</code>'.
231 e.g., prefer <code>Asia/Shanghai</code> to
232 <code>Asia/Beijing</code>.
225 Among locations with similar populations, pick the best-known
233 Among locations with similar populations, pick the best-known
226 location, e.g., prefer '<code>Rome</code>' to
227 '<code>Milan</code>'.
234 location, e.g., prefer <code>Europe/Rome</code> to
235 <code>Europe/Milan</code>.
228 </li>
229 <li>
236 </li>
237 <li>
230 Use the singular form, e.g., prefer '<code>Canary</code>' to
231 '<code>Canaries</code>'.
238 Use the singular form, e.g., prefer <code>Atlantic/Canary</code> to
239 <code>Atlantic/Canaries</code>.
232 </li>
233 <li>
234 Omit common suffixes like '<code>_Islands</code>' and
235 '<code>_City</code>', unless that would lead to ambiguity.
240 </li>
241 <li>
242 Omit common suffixes like '<code>_Islands</code>' and
243 '<code>_City</code>', unless that would lead to ambiguity.
236 E.g., prefer '<code>Cayman</code>' to
237 '<code>Cayman_Islands</code>' and '<code>Guatemala</code>' to
238 '<code>Guatemala_City</code>', but prefer
239 '<code>Mexico_City</code>' to '<code>Mexico</code>'
244 E.g., prefer <code>America/Cayman</code> to
245 <code>America/Cayman_Islands</code> and
246 <code>America/Guatemala</code> to
247 <code>America/Guatemala_City</code>, but prefer
248 <code>America/Mexico_City</code> to
249 <code>America/Mexico</code>
240 because <a href="https://en.wikipedia.org/wiki/Time_in_Mexico">the
241 country of Mexico has several time zones</a>.
242 </li>
243 <li>
244 Use '<code>_</code>' to represent a space.
245 </li>
246 <li>
247 Omit '<code>.</code>' from abbreviations in names.
250 because <a href="https://en.wikipedia.org/wiki/Time_in_Mexico">the
251 country of Mexico has several time zones</a>.
252 </li>
253 <li>
254 Use '<code>_</code>' to represent a space.
255 </li>
256 <li>
257 Omit '<code>.</code>' from abbreviations in names.
248 E.g., prefer '<code>St_Helena</code>' to '<code>St._Helena</code>'.
258 E.g., prefer <code>Atlantic/St_Helena</code> to
259 <code>Atlantic/St._Helena</code>.
249 </li>
250 <li>
251 Do not change established names if they only marginally violate
252 the above guidelines.
260 </li>
261 <li>
262 Do not change established names if they only marginally violate
263 the above guidelines.
253 For example, don't change the existing name '<code>Rome</code>' to
254 '<code>Milan</code>' merely because Milan's population has grown
264 For example, do not change the existing name <code>Europe/Rome</code> to
265 <code>Europe/Milan</code> merely because Milan's population has grown
255 to be somewhat greater than Rome's.
256 </li>
257 <li>
258 If a name is changed, put its old spelling in the
259 '<code>backward</code>' file.
260 This means old spellings will continue to work.
261 </li>
262</ul>

--- 50 unchanged lines hidden (view full) ---

313in decreasing order of importance:
314</p>
315
316<ul>
317 <li>
318 Use three to six characters that are ASCII alphanumerics or
319 '<code>+</code>' or '<code>-</code>'.
320 Previous editions of this database also used characters like
266 to be somewhat greater than Rome's.
267 </li>
268 <li>
269 If a name is changed, put its old spelling in the
270 '<code>backward</code>' file.
271 This means old spellings will continue to work.
272 </li>
273</ul>

--- 50 unchanged lines hidden (view full) ---

324in decreasing order of importance:
325</p>
326
327<ul>
328 <li>
329 Use three to six characters that are ASCII alphanumerics or
330 '<code>+</code>' or '<code>-</code>'.
331 Previous editions of this database also used characters like
321 '<code> </code>' and '<code>?</code>', but these characters have a
322 special meaning to the shell and cause commands like
332 space and '<code>?</code>', but these characters have a
333 special meaning to the
334 <a href="https://en.wikipedia.org/wiki/Unix_shell">UNIX shell</a>
335 and cause commands like
323 '<code><a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set">set</a>
324 `<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html">date</a>`</code>'
325 to have unexpected effects.
326 Previous editions of this guideline required upper-case letters, but the
327 Congressman who introduced
328 <a href="https://en.wikipedia.org/wiki/Chamorro_Time_Zone">Chamorro
329 Standard Time</a> preferred "ChST", so lower-case letters are now
330 allowed.

--- 352 unchanged lines hidden (view full) ---

683 commentary uses the more-general abbreviation <abbr>UT</abbr> for
684 timestamps that might predate 1960.
685 Since <abbr>UT</abbr>, <abbr>UT1</abbr>, etc. disagree slightly,
686 and since pre-1972 <abbr>UTC</abbr> seconds varied in length,
687 interpretation of older timestamps can be problematic when
688 subsecond accuracy is needed.
689 </li>
690 <li>
336 '<code><a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set">set</a>
337 `<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html">date</a>`</code>'
338 to have unexpected effects.
339 Previous editions of this guideline required upper-case letters, but the
340 Congressman who introduced
341 <a href="https://en.wikipedia.org/wiki/Chamorro_Time_Zone">Chamorro
342 Standard Time</a> preferred "ChST", so lower-case letters are now
343 allowed.

--- 352 unchanged lines hidden (view full) ---

696 commentary uses the more-general abbreviation <abbr>UT</abbr> for
697 timestamps that might predate 1960.
698 Since <abbr>UT</abbr>, <abbr>UT1</abbr>, etc. disagree slightly,
699 and since pre-1972 <abbr>UTC</abbr> seconds varied in length,
700 interpretation of older timestamps can be problematic when
701 subsecond accuracy is needed.
702 </li>
703 <li>
691 Civil time was not based on atomic time before 1972, and we don't
704 Civil time was not based on atomic time before 1972, and we do not
692 know the history of
693 <a href="https://en.wikipedia.org/wiki/Earth's_rotation">earth's
694 rotation</a> accurately enough to map <a
695 href="https://en.wikipedia.org/wiki/International_System_of_Units"><abbr
696 title="International System of Units">SI</abbr></a> seconds to
697 historical <a href="https://en.wikipedia.org/wiki/Solar_time">solar time</a>
698 to more than about one-hour accuracy.
699 See: Stephenson FR, Morrison LV, Hohenkerk CY.

--- 15 unchanged lines hidden (view full) ---

715 a leap second, or are slightly slowed while near a leap second.
716 </li>
717 <li>
718 The <code><abbr>tz</abbr></code> database does not represent how
719 uncertain its information is.
720 Ideally it would contain information about when data entries are
721 incomplete or dicey.
722 Partial temporal knowledge is a field of active research, though,
705 know the history of
706 <a href="https://en.wikipedia.org/wiki/Earth's_rotation">earth's
707 rotation</a> accurately enough to map <a
708 href="https://en.wikipedia.org/wiki/International_System_of_Units"><abbr
709 title="International System of Units">SI</abbr></a> seconds to
710 historical <a href="https://en.wikipedia.org/wiki/Solar_time">solar time</a>
711 to more than about one-hour accuracy.
712 See: Stephenson FR, Morrison LV, Hohenkerk CY.

--- 15 unchanged lines hidden (view full) ---

728 a leap second, or are slightly slowed while near a leap second.
729 </li>
730 <li>
731 The <code><abbr>tz</abbr></code> database does not represent how
732 uncertain its information is.
733 Ideally it would contain information about when data entries are
734 incomplete or dicey.
735 Partial temporal knowledge is a field of active research, though,
723 and it's not clear how to apply it here.
736 and it is not clear how to apply it here.
724 </li>
725</ul>
726
727<p>
728In short, many, perhaps most, of the <code><abbr>tz</abbr></code>
729database's pre-1970 and future timestamps are either wrong or
730misleading.
731Any attempt to pass the

--- 27 unchanged lines hidden (view full) ---

759<ul>
760 <li>
761 <p>
762 In POSIX, time display in a process is controlled by the
763 environment variable <code>TZ</code>.
764 Unfortunately, the POSIX
765 <code>TZ</code> string takes a form that is hard to describe and
766 is error-prone in practice.
737 </li>
738</ul>
739
740<p>
741In short, many, perhaps most, of the <code><abbr>tz</abbr></code>
742database's pre-1970 and future timestamps are either wrong or
743misleading.
744Any attempt to pass the

--- 27 unchanged lines hidden (view full) ---

772<ul>
773 <li>
774 <p>
775 In POSIX, time display in a process is controlled by the
776 environment variable <code>TZ</code>.
777 Unfortunately, the POSIX
778 <code>TZ</code> string takes a form that is hard to describe and
779 is error-prone in practice.
767 Also, POSIX <code>TZ</code> strings can't deal with daylight
780 Also, POSIX <code>TZ</code> strings cannot deal with daylight
768 saving time rules not based on the Gregorian calendar (as in
769 Iran), or with situations where more than two time zone
770 abbreviations or <abbr>UT</abbr> offsets are used in an area.
771 </p>
772
773 <p>
774 The POSIX <code>TZ</code> string takes the following form:
775 </p>

--- 93 unchanged lines hidden (view full) ---

869 recompiled to ensure proper results.
870 </li>
871 <li>
872 The <code>TZ</code> environment variable is process-global, which
873 makes it hard to write efficient, thread-safe applications that
874 need access to multiple time zone rulesets.
875 </li>
876 <li>
781 saving time rules not based on the Gregorian calendar (as in
782 Iran), or with situations where more than two time zone
783 abbreviations or <abbr>UT</abbr> offsets are used in an area.
784 </p>
785
786 <p>
787 The POSIX <code>TZ</code> string takes the following form:
788 </p>

--- 93 unchanged lines hidden (view full) ---

882 recompiled to ensure proper results.
883 </li>
884 <li>
885 The <code>TZ</code> environment variable is process-global, which
886 makes it hard to write efficient, thread-safe applications that
887 need access to multiple time zone rulesets.
888 </li>
889 <li>
877 In POSIX, there's no tamper-proof way for a process to learn the
890 In POSIX, there is no tamper-proof way for a process to learn the
878 system's best idea of local wall clock.
879 (This is important for applications that an administrator wants
880 used only at certain times &ndash; without regard to whether the
881 user has fiddled the
882 <code>TZ</code> environment variable.
883 While an administrator can "do everything in <abbr>UT</abbr>" to
884 get around the problem, doing so is inconvenient and precludes
885 handling daylight saving time shifts - as might be required to

--- 82 unchanged lines hidden (view full) ---

968 The functions were inspired by <a href="https://netbsd.org/">NetBSD</a>.
969 </li>
970 <li>
971 A function <code>tzsetwall</code> has been added to arrange for the
972 system's best approximation to local wall clock time to be delivered
973 by subsequent calls to <code>localtime</code>.
974 Source code for portable applications that "must" run on local wall
975 clock time should call <code>tzsetwall</code>;
891 system's best idea of local wall clock.
892 (This is important for applications that an administrator wants
893 used only at certain times &ndash; without regard to whether the
894 user has fiddled the
895 <code>TZ</code> environment variable.
896 While an administrator can "do everything in <abbr>UT</abbr>" to
897 get around the problem, doing so is inconvenient and precludes
898 handling daylight saving time shifts - as might be required to

--- 82 unchanged lines hidden (view full) ---

981 The functions were inspired by <a href="https://netbsd.org/">NetBSD</a>.
982 </li>
983 <li>
984 A function <code>tzsetwall</code> has been added to arrange for the
985 system's best approximation to local wall clock time to be delivered
986 by subsequent calls to <code>localtime</code>.
987 Source code for portable applications that "must" run on local wall
988 clock time should call <code>tzsetwall</code>;
976 if such code is moved to "old" systems that don't
977 provide <code>tzsetwall</code>, you won't be able to generate an
989 if such code is moved to "old" systems that do not
990 provide <code>tzsetwall</code>, you will not be able to generate an
978 executable program.
979 (These functions also arrange for local wall clock time to
980 be used if <code>tzset</code> is called &ndash; directly or
991 executable program.
992 (These functions also arrange for local wall clock time to
993 be used if <code>tzset</code> is called &ndash; directly or
981 indirectly &ndash; and there's no <code>TZ</code> environment
994 indirectly &ndash; and there is no <code>TZ</code> environment
982 variable; portable applications should not, however, rely on this
995 variable; portable applications should not, however, rely on this
983 behavior since it's not the way SVR2 systems behave.)
996 behavior since it is not the way <a
997 href="https://en.wikipedia.org/wiki/UNIX_System_V#SVR2"><abbr>SVR2</abbr></a>
998 systems behave.)
984 </li>
985 <li>
986 Negative <code>time_t</code> values are supported, on systems
987 where <code>time_t</code> is signed.
988 </li>
989 <li>
990 These functions can account for leap seconds, thanks to Bradley White.
991 </li>

--- 43 unchanged lines hidden (view full) ---

1035 </li>
1036</ul>
1037
1038<h3 id="other-portability">Other portability notes</h3>
1039<ul>
1040 <li>
1041 The <a href="https://en.wikipedia.org/wiki/Version_7_Unix">7th Edition
1042 UNIX</a> <code>timezone</code> function is not present in this
999 </li>
1000 <li>
1001 Negative <code>time_t</code> values are supported, on systems
1002 where <code>time_t</code> is signed.
1003 </li>
1004 <li>
1005 These functions can account for leap seconds, thanks to Bradley White.
1006 </li>

--- 43 unchanged lines hidden (view full) ---

1050 </li>
1051</ul>
1052
1053<h3 id="other-portability">Other portability notes</h3>
1054<ul>
1055 <li>
1056 The <a href="https://en.wikipedia.org/wiki/Version_7_Unix">7th Edition
1057 UNIX</a> <code>timezone</code> function is not present in this
1043 package; it's impossible to reliably map <code>timezone</code>'s
1058 package; it is impossible to reliably map <code>timezone</code>'s
1044 arguments (a "minutes west of <abbr>GMT</abbr>" value and a
1045 "daylight saving time in effect" flag) to a time zone
1046 abbreviation, and we refuse to guess.
1047 Programs that in the past used the <code>timezone</code> function
1048 may now examine <code>localtime(&amp;clock)-&gt;tm_zone</code>
1049 (if <code>TM_ZONE</code> is defined) or
1050 <code>tzname[localtime(&amp;clock)-&gt;tm_isdst]</code>
1051 (if <code>HAVE_TZNAME</code> is defined) to learn the correct time
1052 zone abbreviation to use.
1053 </li>
1054 <li>
1059 arguments (a "minutes west of <abbr>GMT</abbr>" value and a
1060 "daylight saving time in effect" flag) to a time zone
1061 abbreviation, and we refuse to guess.
1062 Programs that in the past used the <code>timezone</code> function
1063 may now examine <code>localtime(&amp;clock)-&gt;tm_zone</code>
1064 (if <code>TM_ZONE</code> is defined) or
1065 <code>tzname[localtime(&amp;clock)-&gt;tm_isdst]</code>
1066 (if <code>HAVE_TZNAME</code> is defined) to learn the correct time
1067 zone abbreviation to use.
1068 </li>
1069 <li>
1055 The <abbr>4.2BSD</abbr> <code>gettimeofday</code> function is not
1070 The 1071 href="https://en.wikipedia.org/wiki/History_of_the_Berkeley_Software_Distribution#4.2BSD"><abbr>4.2BSD</abbr></a>
1072 <code>gettimeofday</code> function is not
1056 used in this package.
1057 This formerly let users obtain the current <abbr>UTC</abbr> offset
1058 and <abbr>DST</abbr> flag, but this functionality was removed in
1059 later versions of <abbr>BSD</abbr>.
1060 </li>
1061 <li>
1062 In <abbr>SVR2</abbr>, time conversion fails for near-minimum or
1063 near-maximum <code>time_t</code> values when doing conversions
1073 used in this package.
1074 This formerly let users obtain the current <abbr>UTC</abbr> offset
1075 and <abbr>DST</abbr> flag, but this functionality was removed in
1076 later versions of <abbr>BSD</abbr>.
1077 </li>
1078 <li>
1079 In <abbr>SVR2</abbr>, time conversion fails for near-minimum or
1080 near-maximum <code>time_t</code> values when doing conversions
1064 for places that don't use <abbr>UT</abbr>.
1081 for places that do not use <abbr>UT</abbr>.
1065 This package takes care to do these conversions correctly.
1066 A comment in the source code tells how to get compatibly wrong
1067 results.
1068 </li>
1069 <li>
1070 The functions that are conditionally compiled
1071 if <code>STD_INSPIRED</code> is defined should, at this point, be
1072 looked on primarily as food for thought.

--- 77 unchanged lines hidden (view full) ---

1150</section>
1151
1152<section>
1153 <h2 id="calendar">Calendrical issues</h2>
1154<p>
1155Calendrical issues are a bit out of scope for a time zone database,
1156but they indicate the sort of problems that we would run into if we
1157extended the time zone database further into the past.
1082 This package takes care to do these conversions correctly.
1083 A comment in the source code tells how to get compatibly wrong
1084 results.
1085 </li>
1086 <li>
1087 The functions that are conditionally compiled
1088 if <code>STD_INSPIRED</code> is defined should, at this point, be
1089 looked on primarily as food for thought.

--- 77 unchanged lines hidden (view full) ---

1167</section>
1168
1169<section>
1170 <h2 id="calendar">Calendrical issues</h2>
1171<p>
1172Calendrical issues are a bit out of scope for a time zone database,
1173but they indicate the sort of problems that we would run into if we
1174extended the time zone database further into the past.
1158An excellent resource in this area is Nachum Dershowitz and Edward M.
1159Reingold, <cite><a
1160href="https://www.cs.tau.ac.il/~nachum/calendar-book/third-edition/">Calendrical
1161Calculations: Third Edition</a></cite>, Cambridge University Press (2008).
1175An excellent resource in this area is Edward M. Reingold
1176and Nachum Dershowitz, <cite><a
1177href="https://www.cambridge.org/fr/academic/subjects/computer-science/computing-general-interest/calendrical-calculations-ultimate-edition-4th-edition">Calendrical
1178Calculations: The Ultimate Edition</a></cite>, Cambridge University Press (2018).
1162Other information and sources are given in the file '<code>calendars</code>'
1163in the <code><abbr>tz</abbr></code> distribution.
1164They sometimes disagree.
1165</p>
1166</section>
1167
1168<section>
1169 <h2 id="planets">Time and time zones on other planets</h2>
1170<p>
1171Some people's work schedules
1172use <a href="https://en.wikipedia.org/wiki/Timekeeping on Mars">Mars time</a>.
1179Other information and sources are given in the file '<code>calendars</code>'
1180in the <code><abbr>tz</abbr></code> distribution.
1181They sometimes disagree.
1182</p>
1183</section>
1184
1185<section>
1186 <h2 id="planets">Time and time zones on other planets</h2>
1187<p>
1188Some people's work schedules
1189use <a href="https://en.wikipedia.org/wiki/Timekeeping on Mars">Mars time</a>.
1173Jet Propulsion Laboratory (JPL) coordinators have kept Mars time on
1174and off at least since 1997 for the
1190Jet Propulsion Laboratory (JPL) coordinators kept Mars time on
1191and off during the
1175<a href="https://en.wikipedia.org/wiki/Mars_Pathfinder#End_of_mission">Mars
1176Pathfinder</a> mission.
1192<a href="https://en.wikipedia.org/wiki/Mars_Pathfinder#End_of_mission">Mars
1193Pathfinder</a> mission.
1177Some of their family members have also adapted to Mars time.
1194Some of their family members also adapted to Mars time.
1178Dozens of special Mars watches were built for JPL workers who kept
1179Mars time during the Mars Exploration Rovers mission (2004).
1180These timepieces look like normal Seikos and Citizens but use Mars
1181seconds rather than terrestrial seconds.
1182</p>
1183
1184<p>
1185A Mars solar day is called a "sol" and has a mean period equal to

--- 71 unchanged lines hidden (view full) ---

1257 "<a href="https://www.giss.nasa.gov/tools/mars24/help/notes.html">Technical
1258 Notes on Mars Solar Time as Adopted by the Mars24 Sunclock</a>"
1259 (2015-06-30).
1260 </li>
1261 <li>
1262 Jia-Rui Chong,
1263 "<a href="http://articles.latimes.com/2004/jan/14/science/sci-marstime14">Workdays
1264 Fit for a Martian</a>", <cite>Los Angeles Times</cite>
1195Dozens of special Mars watches were built for JPL workers who kept
1196Mars time during the Mars Exploration Rovers mission (2004).
1197These timepieces look like normal Seikos and Citizens but use Mars
1198seconds rather than terrestrial seconds.
1199</p>
1200
1201<p>
1202A Mars solar day is called a "sol" and has a mean period equal to

--- 71 unchanged lines hidden (view full) ---

1274 "<a href="https://www.giss.nasa.gov/tools/mars24/help/notes.html">Technical
1275 Notes on Mars Solar Time as Adopted by the Mars24 Sunclock</a>"
1276 (2015-06-30).
1277 </li>
1278 <li>
1279 Jia-Rui Chong,
1280 "<a href="http://articles.latimes.com/2004/jan/14/science/sci-marstime14">Workdays
1281 Fit for a Martian</a>", <cite>Los Angeles Times</cite>
1265 (2004-01-14), pp A1, A20-A21.
1282 (2004-01-14), pp A1, A20&ndash;A21.
1266 </li>
1267 <li>
1268 Tom Chmielewski,
1269 "<a href="https://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/">Jet
1270 Lag Is Worse on Mars</a>", <cite>The Atlantic</cite> (2015-02-26)
1271 </li>
1272 <li>
1273 Matt Williams,

--- 14 unchanged lines hidden ---
1283 </li>
1284 <li>
1285 Tom Chmielewski,
1286 "<a href="https://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/">Jet
1287 Lag Is Worse on Mars</a>", <cite>The Atlantic</cite> (2015-02-26)
1288 </li>
1289 <li>
1290 Matt Williams,

--- 14 unchanged lines hidden ---