tzfile.5: Sync from tzdb upstream
[man-pages.git] / man5 / tzfile.5
blob8b4af8b2a2bf7da1a780d780626e282d1a54b469
1 .\" %%%LICENSE_START(PUBLIC_DOMAIN)
2 .\" This file is in the public domain, so clarified as of
3 .\" 1996-06-05 by Arthur David Olson <arthur_david_olson@nih.gov>.
4 .\" %%%LICENSE_END
5 .\"
6 .\" @(#)tzfile.5        7.11
7 .\"
8 .TH TZFILE 5 2017-08-04 "" "Linux Programmer's Manual"
9 .SH NAME
10 tzfile \- time zone information
11 .SH DESCRIPTION
12 .ie '\(lq'' .ds lq \&"\"
13 .el .ds lq \(lq\"
14 .ie '\(rq'' .ds rq \&"\"
15 .el .ds rq \(rq\"
16 .de q
17 \\$3\*(lq\\$1\*(rq\\$2
19 The time zone information files used by
20 .BR tzset (3)
21 are typically found under a directory with a name like
22 .IR /usr/share/zoneinfo .
23 These files begin with a 44-byte header containing the following fields:
24 .IP * 2
25 The magic four-byte ASCII sequence
26 .q "TZif"
27 identifies the file as a time zone information file.
28 .IP *
29 A byte identifying the version of the file's format
30 (as of 2017, either an ASCII NUL, or
31 .q "2",
33 .q "3" ).
34 .IP *
35 Fifteen bytes containing zeros reserved for future use.
36 .IP *
37 Six four-byte integer values
38 written in a standard byte order
39 (the high-order byte of the value is written first).
40 These values are,
41 in order:
42 .RS
43 .TP
44 .I tzh_ttisgmtcnt
45 The number of UT/local indicators stored in the file.
46 .TP
47 .I tzh_ttisstdcnt
48 The number of standard/wall indicators stored in the file.
49 .TP
50 .I tzh_leapcnt
51 The number of leap seconds for which data entries are stored in the file.
52 .TP
53 .I tzh_timecnt
54 The number of transition times for which data entries are stored
55 in the file.
56 .TP
57 .I tzh_typecnt
58 The number of local time types for which data entries are stored
59 in the file (must not be zero).
60 .TP
61 .I tzh_charcnt
62 The number of bytes of time zone abbreviation strings
63 stored in the file.
64 .RE
65 .PP
66 The above header is followed by the following fields, whose lengths
67 vary depend on the contents of the header:
68 .IP * 2
69 .I tzh_timecnt
70 four-byte signed integer values sorted in ascending order.
71 These values are written in standard byte order.
72 Each is used as a transition time (as returned by
73 .BR time (2))
74 at which the rules for computing local time change.
75 .IP *
76 .I tzh_timecnt
77 one-byte unsigned integer values;
78 each one tells which of the different types of local time types
79 described in the file is associated with the time period
80 starting with the same-indexed transition time.
81 These values serve as indices into the next field.
82 .IP *
83 .I tzh_typecnt
84 .I ttinfo
85 entries, each defined as follows:
86 .in +.5i
87 .sp
88 .nf
89 .ta .5i +\w'unsigned char\0\0'u
90 struct ttinfo {
91         int32_t tt_gmtoff;
92         unsigned char   tt_isdst;
93         unsigned char   tt_abbrind;
95 .in -.5i
96 .fi
97 .sp
98 Each structure is written as a four-byte signed integer value for
99 .IR tt_gmtoff ,
100 in a standard byte order, followed by a one-byte value for
101 .I tt_isdst
102 and a one-byte value for
103 .IR tt_abbrind .
104 In each structure,
105 .I tt_gmtoff
106 gives the number of seconds to be added to UT,
107 .I tt_isdst
108 tells whether
109 .I tm_isdst
110 should be set by
111 .BR localtime (3)
113 .I tt_abbrind
114 serves as an index into the array of time zone abbreviation bytes
115 that follow the
116 .I ttinfo
117 structure(s) in the file.
118 .IP *
119 .I tzh_leapcnt
120 pairs of four-byte values, written in standard byte order;
121 the first value of each pair gives the nonnegative time
122 (as returned by
123 .BR time (2))
124 at which a leap second occurs;
125 the second gives the
126 .I total
127 number of leap seconds to be applied during the time period
128 starting at the given time.
129 The pairs of values are sorted in ascending order by time.
130 Each transition is for one leap second, either positive or negative;
131 transitions always separated by at least 28 days minus 1 second.
132 .IP *
133 .I tzh_ttisstdcnt
134 standard/wall indicators, each stored as a one-byte value;
135 they tell whether the transition times associated with local time types
136 were specified as standard time or wall clock time,
137 and are used when a time zone file is used in handling POSIX-style
138 time zone environment variables.
139 .IP *
140 .I tzh_ttisgmtcnt
141 UT/local indicators, each stored as a one-byte value;
142 they tell whether the transition times associated with local time types
143 were specified as UT or local time,
144 and are used when a time zone file is used in handling POSIX-style
145 time zone environment variables.
148 .BR localtime (3)
149 function
150 uses the first standard-time
151 .I ttinfo
152 structure in the file
153 (or simply the first
154 .I ttinfo
155 structure in the absence of a standard-time structure)
156 if either
157 .I tzh_timecnt
158 is zero or the time argument is less than the first transition time recorded
159 in the file.
160 .SS Version 2 format
161 For version-2-format time zone files,
162 the above header and data are followed by a second header and data,
163 identical in format except that
164 eight bytes are used for each transition time or leap second time.
165 (Leap second counts remain four bytes.)
166 After the second header and data comes a newline-enclosed,
167 POSIX-TZ-environment-variable-style string for use in handling instants
168 after the last transition time stored in the file
169 (with nothing between the newlines if there is no POSIX representation for
170 such instants).
171 The POSIX-style string must agree with the local time type after
172 both data's last transition times; for example, given the string
173 .q "WET0WEST,M3.5.0,M10.5.0/3"
174 then if a last transition time is in July, the transition's local time
175 type must specify a daylight-saving time abbreviated
176 .q "WEST"
177 that is one hour east of UT.
178 .SS Version 3 format
179 For version-3-format time zone files, the POSIX-TZ-style string may
180 use two minor extensions to the POSIX TZ format, as described in
181 .IR newtzset (3).
182 First, the hours part of its transition times may be signed and range from
183 \-167 through 167 instead of the POSIX-required unsigned values
184 from 0 through 24.  Second, DST is in effect all year if it starts
185 January 1 at 00:00 and ends December 31 at 24:00 plus the difference
186 between daylight saving and standard time.
188 Future changes to the format may append more data.
189 .SH SEE ALSO
190 .BR time (2),
191 .BR localtime (3),
192 .BR tzset (3),
193 .BR tzselect (8),
194 .BR zdump (8),
195 .BR zic (8)
196 .\" This file is in the public domain, so clarified as of
197 .\" 1996-06-05 by Arthur David Olson.