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