xref: /openbsd/lib/libc/time/tzfile.5 (revision 3cab2bb3)
1.\"	$OpenBSD: tzfile.5,v 1.15 2015/03/14 22:15:09 millert Exp $
2.Dd $Mdocdate: March 14 2015 $
3.Dt TZFILE 5
4.Os
5.Sh NAME
6.Nm tzfile
7.Nd time zone information
8.Sh DESCRIPTION
9The time zone information files used by
10.Xr tzset 3
11begin with the magic characters "TZif" to identify themselves as
12time zone information files,
13followed by a character identifying the version of the file's format
14(as of 2005, either an ASCII NUL or a '2')
15followed by fifteen bytes containing zeroes reserved for future use,
16followed by six four-byte values of type
17.Fa int
18written in a
19.Dq big endian
20byte order
21.Po
22the most significant byte of the value is written first
23.Pc .
24These values are,
25in order:
26.Bl -tag -width "tzh_ttisgmtcnt"
27.It Fa tzh_ttisgmtcnt
28The number of UTC/local indicators stored in the file.
29.It Fa tzh_ttisstdcnt
30The number of standard/wall indicators stored in the file.
31.It Fa tzh_leapcnt
32The number of leap seconds for which data is stored in the file.
33.It Fa tzh_timecnt
34The number of "transition times" for which data is stored
35in the file.
36.It Fa tzh_typecnt
37The number of "local time types" for which data is stored
38in the file (must not be zero).
39.It Fa tzh_charcnt
40The number of characters of "time zone abbreviation strings"
41stored in the file.
42.El
43.Pp
44The above header is followed by
45.Fa tzh_timecnt
46four-byte values of type
47.Fa long ,
48sorted in ascending order.
49These values are written in
50.Dq standard
51byte order.
52Each is used as a transition time
53.Pq as returned by Xr time 3
54at which the rules for computing local time change.
55Next come
56.Fa tzh_timecnt
57one-byte values of type
58.Fa unsigned char ;
59each one tells which of the different types of
60.Dq local time
61types
62described in the file is associated with the same-indexed transition time.
63These values serve as indices into an array of
64.Fa ttinfo
65structures (with
66.Fa tzh_typecnt
67entries) that appears next in the file;
68these structures are defined as follows:
69.Bd -literal -offset indent
70.ta .5i +\w'unsigned int\0\0'u
71struct ttinfo {
72	long	tt_gmtoff;	/* UTC offset in seconds */
73	int	tt_isdst;	/* used to set tm_isdst */
74	int	tt_abbrind;	/* abbreviation list index */
75};
76.Ed
77.Pp
78Each structure is written as a four-byte value for
79.Fa tt_gmtoff
80of type
81.Fa long ,
82in
83.Dq big endian
84byte order, followed by a one-byte value for
85.Fa tt_isdst
86and a one-byte value for
87.Fa tt_abbrind .
88In each structure,
89.Fa tt_gmtoff
90gives the number of seconds to be added to UTC,
91.Fa tt_isdst
92tells whether
93.Fa tm_isdst
94should be set by
95.Xr localtime 3
96and
97.Fa tt_abbrind
98serves as an index into the array of time zone abbreviation characters
99that follow the
100.Fa ttinfo
101structure(s) in the file.
102.Pp
103Then there are
104.Fa tzh_leapcnt
105pairs of four-byte values, written in standard byte order;
106the first value of each pair gives the time
107.Pq as returned by Xr time 3
108at which a leap second occurs;
109the second gives the
110.Em total
111number of leap seconds to be applied after the given time.
112The pairs of values are sorted in ascending order by time.
113.Pp
114Then there are
115.Fa tzh_ttisstdcnt
116standard/wall indicators, each stored as a one-byte value;
117they tell whether the transition times associated with local time types
118were specified as standard time or wall clock time,
119and are used when a time zone file is used in handling POSIX-style
120time zone environment variables.
121.Pp
122Finally there are
123.Fa tzh_ttisgmtcnt
124UTC/local indicators, each stored as a one-byte value;
125they tell whether the transition times associated with local time types
126were specified as UTC or local time,
127and are used when a time zone file is used in handling POSIX-style
128time zone environment variables.
129.Pp
130.Xr localtime 3
131uses the first standard-time
132.Fa ttinfo
133structure in the file,
134or simply the first
135.Fa ttinfo
136structure in the absence of a standard-time structure,
137if either
138.Fa tzh_timecnt
139is zero or the time argument is less than the first transition time recorded
140in the file.
141.Pp
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.
146After the second header and data comes a newline-enclosed,
147POSIX-TZ-environment-variable-style string for use in handling instants
148after the last transition time stored in the file
149(with nothing between the newlines if there is no POSIX representation for
150such instants).
151.Sh SEE ALSO
152.Xr ctime 3
153.\" This file is in the public domain, so clarified as of
154.\" 1996-06-05 by Arthur David Olson.
155