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