1tzfile(5)                     File Formats Manual                    tzfile(5)
2
3
4

NAME

6       tzfile - timezone information
7

DESCRIPTION

9       The timezone information files used by tzset(3) are typically found un‐
10       der a directory with a name like /usr/share/zoneinfo.  These files  use
11       the  format described in Internet RFC 8536.  Each file is a sequence of
12       8-bit bytes.  In a file, a binary integer is represented by a  sequence
13       of  one  or  more bytes in network order (bigendian, or high-order byte
14       first), with all bits significant, a signed binary  integer  is  repre‐
15       sented  using  two's complement, and a boolean is represented by a one-
16       byte binary integer that is either 0 (false) or 1 (true).   The  format
17       begins with a 44-byte header containing the following fields:
18
19       * The  magic  four-byte  ASCII sequence “TZif” identifies the file as a
20         timezone information file.
21
22       * A byte identifying the version of the file's format (as of 2021,  ei‐
23         ther an ASCII NUL, “2”, “3”, or “4”).
24
25       * Fifteen bytes containing zeros reserved for future use.
26
27       * Six four-byte integer values, in the following order:
28
29         tzh_ttisutcnt
30                The  number of UT/local indicators stored in the file.  (UT is
31                Universal Time.)
32
33         tzh_ttisstdcnt
34                The number of standard/wall indicators stored in the file.
35
36         tzh_leapcnt
37                The number of leap seconds for which data entries  are  stored
38                in the file.
39
40         tzh_timecnt
41                The  number  of  transition  times  for which data entries are
42                stored in the file.
43
44         tzh_typecnt
45                The number of local time types  for  which  data  entries  are
46                stored in the file (must not be zero).
47
48         tzh_charcnt
49                The  number  of bytes of time zone abbreviation strings stored
50                in the file.
51
52       The above header is followed by the following fields, whose lengths de‐
53       pend on the contents of the header:
54
55       * tzh_timecnt  four-byte  signed integer values sorted in ascending or‐
56         der.  These values are written in network byte order.  Each  is  used
57         as  a transition time (as returned by time(2)) at which the rules for
58         computing local time change.
59
60       * tzh_timecnt one-byte unsigned integer values; each one but  the  last
61         tells  which  of the different types of local time types described in
62         the file is associated with the time period starting with  the  same-
63         indexed  transition  time  and continuing up to but not including the
64         next transition time.  (The last time type is present only  for  con‐
65         sistency  checking  with  the POSIX-style TZ string described below.)
66         These values serve as indices into the next field.
67
68       * tzh_typecnt ttinfo entries, each defined as follows:
69
70              struct ttinfo {
71                   int32_t        tt_utoff;
72                   unsigned char  tt_isdst;
73                   unsigned char  tt_desigidx;
74              };
75
76         Each structure is written as a four-byte  signed  integer  value  for
77         tt_utoff,  in  network byte order, followed by a one-byte boolean for
78         tt_isdst and a one-byte value for tt_desigidx.   In  each  structure,
79         tt_utoff  gives  the  number  of  seconds to be added to UT, tt_isdst
80         tells whether tm_isdst should be set by localtime(3) and  tt_desigidx
81         serves  as  an  index  into the array of time zone abbreviation bytes
82         that follow the ttinfo entries in the file; if the designated  string
83         is  "-00",  the  ttinfo  entry is a placeholder indicating that local
84         time is unspecified.  The tt_utoff value is never equal to -2**31, to
85         let  32-bit  clients  negate it without overflow.  Also, in realistic
86         applications tt_utoff is in the range  [-89999,  93599]  (i.e.,  more
87         than  -25  hours and less than 26 hours); this allows easy support by
88         implementations  that  already  support  the   POSIX-required   range
89         [-24:59:59, 25:59:59].
90
91       * tzh_charcnt  bytes  that  represent time zone designations, which are
92         null-terminated byte strings, each indexed by the tt_desigidx  values
93         mentioned  above.  The byte strings can overlap if one is a suffix of
94         the other.  The encoding of these strings is not specified.
95
96       * tzh_leapcnt pairs of four-byte values, written in network byte order;
97         the  first value of each pair gives the nonnegative time (as returned
98         by time(2)) at which a leap second occurs or at which the leap second
99         table  expires; the second is a signed integer specifying the correc‐
100         tion, which is the total number of leap seconds to be applied  during
101         the  time period starting at the given time.  The pairs of values are
102         sorted in strictly ascending order by time.  Each  pair  denotes  one
103         leap  second,  either  positive  or negative, except that if the last
104         pair has the same correction as the previous one, the last  pair  de‐
105         notes  the  leap second table's expiration time.  Each leap second is
106         at the end of a UTC calendar month.  The first leap second has a non‐
107         negative  occurrence  time, and is a positive leap second if and only
108         if its correction is positive; the correction for  each  leap  second
109         after the first differs from the previous leap second by either 1 for
110         a positive leap second, or -1 for a negative  leap  second.   If  the
111         leap  second  table  is empty, the leap-second correction is zero for
112         all timestamps; otherwise, for timestamps before the first occurrence
113         time,  the leap-second correction is zero if the first pair's correc‐
114         tion is 1 or -1, and is unspecified otherwise (which can happen  only
115         in files truncated at the start).
116
117       * tzh_ttisstdcnt  standard/wall  indicators,  each stored as a one-byte
118         boolean; they tell whether the transition times associated with local
119         time  types  were  specified  as  standard time or local (wall clock)
120         time.
121
122       * tzh_ttisutcnt UT/local indicators, each stored as a one-byte boolean;
123         they  tell  whether  the  transition times associated with local time
124         types were specified as UT or local time.  If a UT/local indicator is
125         set, the corresponding standard/wall indicator must also be set.
126
127       The  standard/wall and UT/local indicators were designed for transform‐
128       ing a TZif file's transition times into transitions appropriate for an‐
129       other time zone specified via a POSIX-style TZ string that lacks rules.
130       For example, when TZ="EET-2EEST" and there is no TZif file "EET-2EEST",
131       the  idea  was  to adapt the transition times from a TZif file with the
132       well-known name "posixrules" that is present only for this purpose  and
133       is  a  copy  of  the file "Europe/Brussels", a file with a different UT
134       offset.  POSIX does not specify this obsolete  transformational  behav‐
135       ior,  the  default rules are installation-dependent, and no implementa‐
136       tion is known to support this feature  for  timestamps  past  2037,  so
137       users   desiring  (say)  Greek  time  should  instead  specify  TZ="Eu‐
138       rope/Athens"  for  better  historical   coverage,   falling   back   on
139       TZ="EET-2EEST,M3.5.0/3,M10.5.0/4"  if POSIX conformance is required and
140       older timestamps need not be handled accurately.
141
142       The localtime(3) function normally uses the first ttinfo  structure  in
143       the  file  if  either  tzh_timecnt is zero or the time argument is less
144       than the first transition time recorded in the file.
145
146   Version 2 format
147       For version-2-format timezone files, the above header and data are fol‐
148       lowed  by  a  second  header  and data, identical in format except that
149       eight bytes are used for each transition  time  or  leap  second  time.
150       (Leap  second  counts  remain four bytes.)  After the second header and
151       data  comes  a  newline-enclosed,   POSIX-TZ-environment-variable-style
152       string  for  use  in  handling  instants after the last transition time
153       stored in the file or for all instants if the file has no  transitions.
154       The POSIX-style TZ string is empty (i.e., nothing between the newlines)
155       if there is  no  POSIX-style  representation  for  such  instants.   If
156       nonempty, the POSIX-style TZ string must agree with the local time type
157       after the last transition time if present in the eight-byte  data;  for
158       example,  given  the  string “WET0WEST,M3.5.0/1,M10.5.0” then if a last
159       transition time is in July, the transition's local time type must spec‐
160       ify  a daylight-saving time abbreviated “WEST” that is one hour east of
161       UT.  Also, if there is at least one transition, time type 0 is  associ‐
162       ated  with  the  time period from the indefinite past up to but not in‐
163       cluding the earliest transition time.
164
165   Version 3 format
166       For version-3-format timezone files, the POSIX-TZ-style string may  use
167       two   minor  extensions  to  the  POSIX  TZ  format,  as  described  in
168       newtzset(3).  First, the hours part of  its  transition  times  may  be
169       signed  and  range  from -167 through 167 instead of the POSIX-required
170       unsigned values from 0 through 24.  Second, DST is in effect  all  year
171       if  it starts January 1 at 00:00 and ends December 31 at 24:00 plus the
172       difference between daylight saving and standard time.
173
174   Version 4 format
175       For version-4-format TZif files, the first leap second record can  have
176       a  correction that is neither +1 nor -1, to represent truncation of the
177       TZif file at the start.  Also, if two or more leap  second  transitions
178       are  present  and  the last entry's correction equals the previous one,
179       the last entry denotes the expiration of the leap second table  instead
180       of  a  leap  second; timestamps after this expiration are unreliable in
181       that future releases will likely add leap second entries after the  ex‐
182       piration,  and  the  added leap seconds will change how post-expiration
183       timestamps are treated.
184
185   Interoperability considerations
186       Future changes to the format may append more data.
187
188       Version 1 files are considered a legacy format and should not be gener‐
189       ated,  as  they  do  not  support transition times after the year 2038.
190       Readers that understand only Version 1 must ignore any  data  that  ex‐
191       tends beyond the calculated end of the version 1 data block.
192
193       Other than version 1, writers should generate the lowest version number
194       needed by a file's data.  For example, a writer should generate a  ver‐
195       sion  4  file  only if its leap second table either expires or is trun‐
196       cated at the start.  Likewise, a writer not generating a version 4 file
197       should  generate a version 3 file only if TZ string extensions are nec‐
198       essary to accurately model transition times.
199
200       The sequence of time changes defined by the version 1 header  and  data
201       block  should  be a contiguous sub-sequence of the time changes defined
202       by the version 2+ header and data  block,  and  by  the  footer.   This
203       guideline  helps obsolescent version 1 readers agree with current read‐
204       ers about timestamps within the contiguous sub-sequence.  It also  lets
205       writers not supporting obsolescent readers use a tzh_timecnt of zero in
206       the version 1 data block to save space.
207
208       When a TZif file contains a leap second  table  expiration  time,  TZif
209       readers  should either refuse to process post-expiration timestamps, or
210       process them as if the expiration time did not exist (possibly with  an
211       error indication).
212
213       Time zone designations should consist of at least three (3) and no more
214       than six (6) ASCII characters from the set of alphanumerics,  “-”,  and
215       “+”.   This  is for compatibility with POSIX requirements for time zone
216       abbreviations.
217
218       When reading a version 2 or higher file, readers should ignore the ver‐
219       sion  1  header  and data block except for the purpose of skipping over
220       them.
221
222       Readers should calculate the total lengths  of  the  headers  and  data
223       blocks and check that they all fit within the actual file size, as part
224       of a validity check for the file.
225
226       When a positive leap second occurs, readers should append an extra sec‐
227       ond to the local minute containing the second just before the leap sec‐
228       ond.  If this occurs when the UTC offset is not a multiple of  60  sec‐
229       onds,  the leap second occurs earlier than the last second of the local
230       minute and the minute's remaining local seconds are numbered through 60
231       instead of the usual 59; the UTC offset is unaffected.
232
233   Common interoperability issues
234       This  section  documents  common  problems  in  reading or writing TZif
235       files.  Most of these are problems in generating TZif files for use  by
236       older readers.  The goals of this section are:
237
238       * to help TZif writers output files that avoid common pitfalls in older
239         or buggy TZif readers,
240
241       * to help TZif readers avoid common pitfalls when reading files  gener‐
242         ated by future TZif writers, and
243
244       * to  help  any  future specification authors see what sort of problems
245         arise when the TZif format is changed.
246
247       When new versions of the TZif format have been defined, a  design  goal
248       has  been  that  a  reader can successfully use a TZif file even if the
249       file is of a later TZif version than what the reader was designed  for.
250       When  complete  compatibility  was not achieved, an attempt was made to
251       limit glitches to rarely used timestamps and allow simple partial work‐
252       arounds  in  writers  designed to generate new-version data useful even
253       for older-version readers.  This section  attempts  to  document  these
254       compatibility issues and workarounds, as well as to document other com‐
255       mon bugs in readers.
256
257       Interoperability problems with TZif include the following:
258
259       * Some readers examine only version 1 data.  As a partial workaround, a
260         writer  can  output  as  much version 1 data as possible.  However, a
261         reader should ignore version 1 data, and should use version  2+  data
262         even if the reader's native timestamps have only 32 bits.
263
264       * Some  readers designed for version 2 might mishandle timestamps after
265         a version 3 or higher file's last  transition,  because  they  cannot
266         parse  extensions to POSIX in the TZ-like string.  As a partial work‐
267         around, a writer can output more transitions than necessary, so  that
268         only far-future timestamps are mishandled by version 2 readers.
269
270       * Some readers designed for version 2 do not support permanent daylight
271         saving time  with  transitions  after  24:00  –  e.g.,  a  TZ  string
272         “EST5EDT,0/0,J365/25” denoting permanent Eastern Daylight Time (-04).
273         As a workaround, a writer can substitute standard time for  two  time
274         zones  east,  e.g.,  “XXX3EDT4,0/0,J365/23”  for  a  time zone with a
275         never-used standard time (XXX, -03) and negative daylight saving time
276         (EDT, -04) all year.  Alternatively, as a partial workaround a writer
277         can substitute standard time for the next  time  zone  east  –  e.g.,
278         “AST4” for permanent Atlantic Standard Time (-04).
279
280       * Some  readers  designed  for  version 2 or 3, and that require strict
281         conformance to RFC 8536, reject version 4 files whose leap second ta‐
282         bles are truncated at the start or that end in expiration times.
283
284       * Some readers ignore the footer, and instead predict future timestamps
285         from the time type of the last transition.  As a partial  workaround,
286         a writer can output more transitions than necessary.
287
288       * Some  readers  do not use time type 0 for timestamps before the first
289         transition, in that they infer a time type  using  a  heuristic  that
290         does  not  always  select  time  type  0.  As a partial workaround, a
291         writer can output a dummy (no-op) first transition at an early time.
292
293       * Some readers mishandle timestamps before the  first  transition  that
294         has  a  timestamp  not  less  than -2**31.  Readers that support only
295         32-bit timestamps are likely to be more prone to  this  problem,  for
296         example,  when they process 64-bit transitions only some of which are
297         representable in 32 bits.  As a partial workaround, a writer can out‐
298         put a dummy transition at timestamp -2**31.
299
300       * Some  readers mishandle a transition if its timestamp has the minimum
301         possible signed 64-bit value.  Timestamps less than  -2**59  are  not
302         recommended.
303
304       * Some  readers  mishandle  POSIX-style  TZ strings that contain “<” or
305         “>”.  As a partial workaround, a writer can avoid using  “<”  or  “>”
306         for time zone abbreviations containing only alphabetic characters.
307
308       * Many readers mishandle time zone abbreviations that contain non-ASCII
309         characters.  These characters are not recommended.
310
311       * Some readers may mishandle time zone abbreviations that contain fewer
312         than  3  or  more than 6 characters, or that contain ASCII characters
313         other than alphanumerics, “-”, and “+”.  These abbreviations are  not
314         recommended.
315
316       * Some  readers  mishandle TZif files that specify daylight-saving time
317         UT offsets that are less than the UT offsets  for  the  corresponding
318         standard  time.  These readers do not support locations like Ireland,
319         which   uses   the   equivalent    of    the    POSIX    TZ    string
320         “IST-1GMT0,M10.5.0,M3.5.0/1”,  observing  standard time (IST, +01) in
321         summer and daylight saving time (GMT, +00) in winter.  As  a  partial
322         workaround,  a writer can output data for the equivalent of the POSIX
323         TZ string “GMT0IST,M3.5.0/1,M10.5.0”, thus swapping standard and day‐
324         light saving time.  Although this workaround misidentifies which part
325         of the year uses daylight saving time, it records UT offsets and time
326         zone abbreviations correctly.
327
328       * Some  readers generate ambiguous timestamps for positive leap seconds
329         that occur when the UTC offset is not a multiple of 60 seconds.   For
330         example,  in a timezone with UTC offset +01:23:45 and with a positive
331         leap second 78796801 (1972-06-30 23:59:60 UTC), some readers will map
332         both  78796800  and  78796801 to 01:23:45 local time the next day in‐
333         stead of mapping the latter to 01:23:46, and they will  map  78796815
334         to  01:23:59 instead of to 01:23:60.  This has not yet been a practi‐
335         cal problem, since no civil authority has observed such  UTC  offsets
336         since leap seconds were introduced in 1972.
337
338       Some  interoperability  problems  are  reader bugs that are listed here
339       mostly as warnings to developers of readers.
340
341       * Some readers do not support negative timestamps.  Developers of  dis‐
342         tributed  applications  should keep this in mind if they need to deal
343         with pre-1970 data.
344
345       * Some readers mishandle timestamps before the  first  transition  that
346         has  a  nonnegative  timestamp.  Readers that do not support negative
347         timestamps are likely to be more prone to this problem.
348
349       * Some readers mishandle time zone abbreviations like “-08”  that  con‐
350         tain “+”, “-”, or digits.
351
352       * Some  readers  mishandle  UT  offsets that are out of the traditional
353         range of -12 through +12 hours, and so do not support locations  like
354         Kiritimati that are outside this range.
355
356       * Some  readers  mishandle  UT offsets in the range [-3599, -1] seconds
357         from UT, because they integer-divide the offset by 3600 to get 0  and
358         then display the hour part as “+00”.
359
360       * Some  readers  mishandle  UT  offsets  that are not a multiple of one
361         hour, or of 15 minutes, or of 1 minute.
362

SEE ALSO

364       time(2), localtime(3), tzset(3), tzselect(8), zdump(8), zic(8).
365
366       Olson A, Eggert P,  Murchison  K.  The  Time  Zone  Information  Format
367       (TZif).   2019  Feb.   Internet RFC 8536 ⟨https://datatracker.ietf.org/
368       doc/html/rfc8536⟩    doi:10.17487/RFC8536    ⟨https://doi.org/10.17487/
369       RFC8536⟩.
370
371
372
373Time Zone Database                                                   tzfile(5)
Impressum