0c907bc0d05e93008dbe2a9a28d4c0b3c733d193
[platform/upstream/tzdata.git] / tzfile.5
1 .TH TZFILE 5
2 .SH NAME
3 tzfile \- time zone information
4 .SH DESCRIPTION
5 .ie '\(lq'' .ds lq \&"\"
6 .el .ds lq \(lq\"
7 .ie '\(rq'' .ds rq \&"\"
8 .el .ds rq \(rq\"
9 .de q
10 \\$3\*(lq\\$1\*(rq\\$2
11 ..
12 The time zone information files used by
13 .IR tzset (3)
14 begin with the magic characters "TZif" to identify them as
15 time zone information files,
16 followed by a character identifying the version of the file's format
17 (as of 2013, either an ASCII NUL, or '2', or '3')
18 followed by fifteen bytes containing zeroes reserved for future use,
19 followed by six four-byte integer values
20 written in a standard byte order
21 (the high-order byte of the value is written first).
22 These values are,
23 in order:
24 .TP
25 .I tzh_ttisgmtcnt
26 The number of UT/local indicators stored in the file.
27 .TP
28 .I tzh_ttisstdcnt
29 The number of standard/wall indicators stored in the file.
30 .TP
31 .I tzh_leapcnt
32 The number of leap seconds for which data entries are stored in the file.
33 .TP
34 .I tzh_timecnt
35 The number of transition times for which data entries are stored
36 in the file.
37 .TP
38 .I tzh_typecnt
39 The number of local time types for which data entries are stored
40 in the file (must not be zero).
41 .TP
42 .I tzh_charcnt
43 The number of characters of time zone abbreviation strings
44 stored in the file.
45 .PP
46 The above header is followed by
47 .I tzh_timecnt
48 four-byte signed integer values sorted in ascending order.
49 These values are written in standard byte order.
50 Each is used as a transition time (as returned by
51 .IR time (2))
52 at which the rules for computing local time change.
53 Next come
54 .I tzh_timecnt
55 one-byte unsigned integer values;
56 each one tells which of the different types of local time types
57 described in the file is associated with the time period
58 starting with the same-indexed transition time.
59 These values serve as indices into an array of
60 .I ttinfo
61 structures (with
62 .I tzh_typecnt
63 entries) that appears next in the file;
64 these structures are defined as follows:
65 .in +.5i
66 .sp
67 .nf
68 .ta .5i +\w'unsigned char\0\0'u
69 struct ttinfo {
70         int32_t tt_gmtoff;
71         unsigned char   tt_isdst;
72         unsigned char   tt_abbrind;
73 };
74 .in -.5i
75 .fi
76 .sp
77 Each structure is written as a four-byte signed integer value for
78 .IR tt_gmtoff ,
79 in a standard byte order, followed by a one-byte value for
80 .I tt_isdst
81 and a one-byte value for
82 .IR tt_abbrind .
83 In each structure,
84 .I tt_gmtoff
85 gives the number of seconds to be added to UT,
86 .I tt_isdst
87 tells whether
88 .I tm_isdst
89 should be set by
90 .I localtime (3)
91 and
92 .I tt_abbrind
93 serves as an index into the array of time zone abbreviation characters
94 that follow the
95 .I ttinfo
96 structure(s) in the file.
97 .PP
98 Then there are
99 .I tzh_leapcnt
100 pairs of four-byte values, written in standard byte order;
101 the first value of each pair gives the time
102 (as returned by
103 .IR time(2))
104 at which a leap second occurs;
105 the second gives the
106 .I total
107 number of leap seconds to be applied during the time period
108 starting at the given time.
109 The pairs of values are sorted in ascending order by time.
110 .PP
111 Then there are
112 .I tzh_ttisstdcnt
113 standard/wall indicators, each stored as a one-byte value;
114 they tell whether the transition times associated with local time types
115 were specified as standard time or wall clock time,
116 and are used when a time zone file is used in handling POSIX-style
117 time zone environment variables.
118 .PP
119 Finally there are
120 .I tzh_ttisgmtcnt
121 UT/local indicators, each stored as a one-byte value;
122 they tell whether the transition times associated with local time types
123 were specified as UT or local time,
124 and are used when a time zone file is used in handling POSIX-style
125 time zone environment variables.
126 .PP
127 .I Localtime
128 uses the first standard-time
129 .I ttinfo
130 structure in the file
131 (or simply the first
132 .I ttinfo
133 structure in the absence of a standard-time structure)
134 if either
135 .I tzh_timecnt
136 is zero or the time argument is less than the first transition time recorded
137 in the file.
138 .PP
139 For version-2-format time zone files,
140 the above header and data are followed by a second header and data,
141 identical in format except that
142 eight bytes are used for each transition time or leap second time.
143 After the second header and data comes a newline-enclosed,
144 POSIX-TZ-environment-variable-style string for use in handling instants
145 after the last transition time stored in the file
146 (with nothing between the newlines if there is no POSIX representation for
147 such instants).
148 The POSIX-style string must must agree with the local time type after
149 both data's last transition times; for example, given the string
150 .q "WET0WEST,M3.5.0,M10.5.0/3"
151 then if a last transition time is in July, the transition's local time
152 type must specify a daylight-saving time abbreviated
153 .q "WEST"
154 that is one hour east of UT.
155 .PP
156 For version-3-format time zone files, the POSIX-TZ-style string may
157 use two minor extensions to the POSIX TZ format, as described in
158 .IR newtzset (3).
159 First, the hours part of its transition times may be signed and range from
160 \-167 through 167 instead of the POSIX-required unsigned values
161 from 0 through 24.  Second, DST is in effect all year if it starts
162 January 1 at 00:00 and ends December 31 at 24:00 plus the difference
163 between daylight saving and standard time.
164 .PP
165 Future changes to the format may append more data.
166 .SH SEE ALSO
167 newctime(3), newtzset(3), zdump(8), zic(8)
168 .\" This file is in the public domain, so clarified as of
169 .\" 1996-06-05 by Arthur David Olson.