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