1TZFILE(5) File Formats Manual TZFILE(5) 2 3NAME 4 tzfile - timezone information 5 6DESCRIPTION 7 The timezone information files used by tzset(3) are typically found 8 under a directory with a name like /usr/share/zoneinfo. These files 9 use the format described in Internet RFC 8536. Each file is a sequence 10 of 8-bit bytes. In a file, a binary integer is represented by a 11 sequence of one or more bytes in network order (bigendian, or high- 12 order byte first), with all bits significant, a signed binary integer 13 is represented using two's complement, and a boolean is represented by 14 a one-byte binary integer that is either 0 (false) or 1 (true). The 15 format begins with a 44-byte header containing the following fields: 16 17 * The magic four-byte ASCII sequence "TZif" identifies the file as a 18 timezone information file. 19 20 * A byte identifying the version of the file's format (as of 2017, 21 either an ASCII NUL, or "2", or "3"). 22 23 * Fifteen bytes containing zeros reserved for future use. 24 25 * Six four-byte integer values, in the following order: 26 27 tzh_ttisutcnt 28 The number of UT/local indicators stored in the file. (UT is 29 Universal Time.) 30 31 tzh_ttisstdcnt 32 The number of standard/wall indicators stored in the file. 33 34 tzh_leapcnt 35 The number of leap seconds for which data entries are stored 36 in the file. 37 38 tzh_timecnt 39 The number of transition times for which data entries are 40 stored in the file. 41 42 tzh_typecnt 43 The number of local time types for which data entries are 44 stored in the file (must not be zero). 45 46 tzh_charcnt 47 The number of bytes of time zone abbreviation strings stored 48 in the file. 49 50 The above header is followed by the following fields, whose lengths 51 depend on the contents of the header: 52 53 * tzh_timecnt four-byte signed integer values sorted in ascending 54 order. These values are written in network byte order. Each is used 55 as a transition time (as returned by time(2)) at which the rules for 56 computing local time change. 57 58 * tzh_timecnt one-byte unsigned integer values; each one but the last 59 tells which of the different types of local time types described in 60 the file is associated with the time period starting with the same- 61 indexed transition time and continuing up to but not including the 62 next transition time. (The last time type is present only for 63 consistency checking with the POSIX-style TZ string described below.) 64 These values serve as indices into the next field. 65 66 * tzh_typecnt ttinfo entries, each defined as follows: 67 68 struct ttinfo { 69 int32_t tt_utoff; 70 unsigned char tt_isdst; 71 unsigned char tt_desigidx; 72 }; 73 74 Each structure is written as a four-byte signed integer value for 75 tt_utoff, in network byte order, followed by a one-byte boolean for 76 tt_isdst and a one-byte value for tt_desigidx. In each structure, 77 tt_utoff gives the number of seconds to be added to UT, tt_isdst 78 tells whether tm_isdst should be set by localtime(3) and tt_desigidx 79 serves as an index into the array of time zone abbreviation bytes 80 that follow the ttinfo structure(s) in the file. The tt_utoff value 81 is never equal to -2**31, to let 32-bit clients negate it without 82 overflow. Also, in realistic applications tt_utoff is in the range 83 [-89999, 93599] (i.e., more than -25 hours and less than 26 hours); 84 this allows easy support by implementations that already support the 85 POSIX-required range [-24:59:59, 25:59:59]. 86 87 * tzh_leapcnt pairs of four-byte values, written in network byte order; 88 the first value of each pair gives the nonnegative time (as returned 89 by time(2)) at which a leap second occurs; the second is a signed 90 integer specifying the total number of leap seconds to be applied 91 during the time period starting at the given time. The pairs of 92 values are sorted in ascending order by time. Each transition is for 93 one leap second, either positive or negative; transitions always 94 separated by at least 28 days minus 1 second. 95 96 * tzh_ttisstdcnt standard/wall indicators, each stored as a one-byte 97 boolean; they tell whether the transition times associated with local 98 time types were specified as standard time or local (wall clock) 99 time. 100 101 * tzh_ttisutcnt UT/local indicators, each stored as a one-byte boolean; 102 they tell whether the transition times associated with local time 103 types were specified as UT or local time. If a UT/local indicator is 104 set, the corresponding standard/wall indicator must also be set. 105 106 The standard/wall and UT/local indicators were designed for 107 transforming a TZif file's transition times into transitions 108 appropriate for another time zone specified via a POSIX-style TZ string 109 that lacks rules. For example, when TZ="EET-2EEST" and there is no 110 TZif file "EET-2EEST", the idea was to adapt the transition times from 111 a TZif file with the well-known name "posixrules" that is present only 112 for this purpose and is a copy of the file "Europe/Brussels", a file 113 with a different UT offset. POSIX does not specify this obsolete 114 transformational behavior, the default rules are installation- 115 dependent, and no implementation is known to support this feature for 116 timestamps past 2037, so users desiring (say) Greek time should instead 117 specify TZ="Europe/Athens" for better historical coverage, falling back 118 on TZ="EET-2EEST,M3.5.0/3,M10.5.0/4" if POSIX conformance is required 119 and older timestamps need not be handled accurately. 120 121 The localtime(3) function normally uses the first ttinfo structure in 122 the file if either tzh_timecnt is zero or the time argument is less 123 than the first transition time recorded in the file. 124 125 Version 2 format 126 For version-2-format timezone files, the above header and data are 127 followed by a second header and data, identical in format except that 128 eight bytes are used for each transition time or leap second time. 129 (Leap second counts remain four bytes.) After the second header and 130 data comes a newline-enclosed, POSIX-TZ-environment-variable-style 131 string for use in handling instants after the last transition time 132 stored in the file or for all instants if the file has no transitions. 133 The POSIX-style TZ string is empty (i.e., nothing between the newlines) 134 if there is no POSIX representation for such instants. If nonempty, 135 the POSIX-style TZ string must agree with the local time type after the 136 last transition time if present in the eight-byte data; for example, 137 given the string "WET0WEST,M3.5.0,M10.5.0/3" then if a last transition 138 time is in July, the transition's local time type must specify a 139 daylight-saving time abbreviated "WEST" that is one hour east of UT. 140 Also, if there is at least one transition, time type 0 is associated 141 with the time period from the indefinite past up to but not including 142 the earliest transition time. 143 144 Version 3 format 145 For version-3-format timezone files, the POSIX-TZ-style string may use 146 two minor extensions to the POSIX TZ format, as described in 147 newtzset(3). First, the hours part of its transition times may be 148 signed and range from -167 through 167 instead of the POSIX-required 149 unsigned values from 0 through 24. Second, DST is in effect all year 150 if it starts January 1 at 00:00 and ends December 31 at 24:00 plus the 151 difference between daylight saving and standard time. 152 153 Interoperability considerations 154 Future changes to the format may append more data. 155 156 Version 1 files are considered a legacy format and should be avoided, 157 as they do not support transition times after the year 2038. Readers 158 that only understand Version 1 must ignore any data that extends beyond 159 the calculated end of the version 1 data block. 160 161 Writers should generate a version 3 file if TZ string extensions are 162 necessary to accurately model transition times. Otherwise, version 2 163 files should be generated. 164 165 The sequence of time changes defined by the version 1 header and data 166 block should be a contiguous subsequence of the time changes defined by 167 the version 2+ header and data block, and by the footer. This 168 guideline helps obsolescent version 1 readers agree with current 169 readers about timestamps within the contiguous subsequence. It also 170 lets writers not supporting obsolescent readers use a tzh_timecnt of 171 zero in the version 1 data block to save space. 172 173 Time zone designations should consist of at least three (3) and no more 174 than six (6) ASCII characters from the set of alphanumerics, "-", and 175 "+". This is for compatibility with POSIX requirements for time zone 176 abbreviations. 177 178 When reading a version 2 or 3 file, readers should ignore the version 1 179 header and data block except for the purpose of skipping over them. 180 181 Readers should calculate the total lengths of the headers and data 182 blocks and check that they all fit within the actual file size, as part 183 of a validity check for the file. 184 185 Common interoperability issues 186 This section documents common problems in reading or writing TZif 187 files. Most of these are problems in generating TZif files for use by 188 older readers. The goals of this section are: 189 190 * to help TZif writers output files that avoid common pitfalls in older 191 or buggy TZif readers, 192 193 * to help TZif readers avoid common pitfalls when reading files 194 generated by future TZif writers, and 195 196 * to help any future specification authors see what sort of problems 197 arise when the TZif format is changed. 198 199 When new versions of the TZif format have been defined, a design goal 200 has been that a reader can successfully use a TZif file even if the 201 file is of a later TZif version than what the reader was designed for. 202 When complete compatibility was not achieved, an attempt was made to 203 limit glitches to rarely-used timestamps, and to allow simple partial 204 workarounds in writers designed to generate new-version data useful 205 even for older-version readers. This section attempts to document 206 these compatibility issues and workarounds, as well as to document 207 other common bugs in readers. 208 209 Interoperability problems with TZif include the following: 210 211 * Some readers examine only version 1 data. As a partial workaround, a 212 writer can output as much version 1 data as possible. However, a 213 reader should ignore version 1 data, and should use version 2+ data 214 even if the reader's native timestamps have only 32 bits. 215 216 * Some readers designed for version 2 might mishandle timestamps after 217 a version 3 file's last transition, because they cannot parse 218 extensions to POSIX in the TZ-like string. As a partial workaround, 219 a writer can output more transitions than necessary, so that only 220 far-future timestamps are mishandled by version 2 readers. 221 222 * Some readers designed for version 2 do not support permanent daylight 223 saving time, e.g., a TZ string "EST5EDT,0/0,J365/25" denoting 224 permanent Eastern Daylight Time (-04). As a partial workaround, a 225 writer can substitute standard time for the next time zone east, 226 e.g., "AST4" for permanent Atlantic Standard Time (-04). 227 228 * Some readers ignore the footer, and instead predict future timestamps 229 from the time type of the last transition. As a partial workaround, 230 a writer can output more transitions than necessary. 231 232 * Some readers do not use time type 0 for timestamps before the first 233 transition, in that they infer a time type using a heuristic that 234 does not always select time type 0. As a partial workaround, a 235 writer can output a dummy (no-op) first transition at an early time. 236 237 * Some readers mishandle timestamps before the first transition that 238 has a timestamp not less than -2**31. Readers that support only 239 32-bit timestamps are likely to be more prone to this problem, for 240 example, when they process 64-bit transitions only some of which are 241 representable in 32 bits. As a partial workaround, a writer can 242 output a dummy transition at timestamp -2**31. 243 244 * Some readers mishandle a transition if its timestamp has the minimum 245 possible signed 64-bit value. Timestamps less than -2**59 are not 246 recommended. 247 248 * Some readers mishandle POSIX-style TZ strings that contain "<" or 249 ">". As a partial workaround, a writer can avoid using "<" or ">" 250 for time zone abbreviations containing only alphabetic characters. 251 252 * Many readers mishandle time zone abbreviations that contain non-ASCII 253 characters. These characters are not recommended. 254 255 * Some readers may mishandle time zone abbreviations that contain fewer 256 than 3 or more than 6 characters, or that contain ASCII characters 257 other than alphanumerics, "-", and "+". These abbreviations are not 258 recommended. 259 260 * Some readers mishandle TZif files that specify daylight-saving time 261 UT offsets that are less than the UT offsets for the corresponding 262 standard time. These readers do not support locations like Ireland, 263 which uses the equivalent of the POSIX TZ string 264 "IST-1GMT0,M10.5.0,M3.5.0/1", observing standard time (IST, +01) in 265 summer and daylight saving time (GMT, +00) in winter. As a partial 266 workaround, a writer can output data for the equivalent of the POSIX 267 TZ string "GMT0IST,M3.5.0/1,M10.5.0", thus swapping standard and 268 daylight saving time. Although this workaround misidentifies which 269 part of the year uses daylight saving time, it records UT offsets and 270 time zone abbreviations correctly. 271 272 Some interoperability problems are reader bugs that are listed here 273 mostly as warnings to developers of readers. 274 275 * Some readers do not support negative timestamps. Developers of 276 distributed applications should keep this in mind if they need to 277 deal with pre-1970 data. 278 279 * Some readers mishandle timestamps before the first transition that 280 has a nonnegative timestamp. Readers that do not support negative 281 timestamps are likely to be more prone to this problem. 282 283 * Some readers mishandle time zone abbreviations like "-08" that 284 contain "+", "-", or digits. 285 286 * Some readers mishandle UT offsets that are out of the traditional 287 range of -12 through +12 hours, and so do not support locations like 288 Kiritimati that are outside this range. 289 290 * Some readers mishandle UT offsets in the range [-3599, -1] seconds 291 from UT, because they integer-divide the offset by 3600 to get 0 and 292 then display the hour part as "+00". 293 294 * Some readers mishandle UT offsets that are not a multiple of one 295 hour, or of 15 minutes, or of 1 minute. 296 297SEE ALSO 298 time(2), localtime(3), tzset(3), tzselect(8), zdump(8), zic(8). 299 300 Olson A, Eggert P, Murchison K. The Time Zone Information Format 301 (TZif). 2019 Feb. Internet RFC 8536 <https://www.rfc-editor.org/info/ 302 rfc8536> doi:10.17487/RFC8536 <https://doi.org/10.17487/RFC8536>. 303 304 TZFILE(5) 305