xref: /openbsd/lib/libc/time/tzfile.5 (revision 78b63d65)
1.\"	$OpenBSD: tzfile.5,v 1.8 1999/07/09 13:35:21 aaron Exp $
2.Dd May 24, 1999
3.Dt TZFILE 5
4.Os
5.Sh NAME
6.Nm tzfile
7.Nd time zone information
8.Sh SYNOPSIS
9.Fd #include <tzfile.h>
10.Sh DESCRIPTION
11The time zone information files used by
12.Xr tzset 3
13begin with the magic characters "TZif" to identify themselves as
14time zone information files,
15followed by sixteen bytes reserved for future use,
16followed by six four-byte values of type
17.Fa long
18written in a
19.Dq standard
20byte order
21.Po
22the high-order 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 that appears next in the file;
66these structures are defined as follows:
67.Bd -literal -offset indent
68.ta .5i +\w'unsigned int\0\0'u
69struct ttinfo {
70	long	tt_gmtoff;
71	int	tt_isdst;
72	unsigned int	tt_abbrind;
73};
74.Ed
75.Pp
76Each structure is written as a four-byte value for
77.Fa tt_gmtoff
78of type
79.Fa long ,
80in a standard byte order, followed by a one-byte value for
81.Fa tt_isdst
82and a one-byte value for
83.Fa tt_abbrind .
84In each structure,
85.Fa tt_gmtoff
86gives the number of seconds to be added to UTC,
87.Fa tt_isdst
88tells whether
89.Fa tm_isdst
90should be set by
91.Xr localtime 3
92and
93.Fa tt_abbrind
94serves as an index into the array of time zone abbreviation characters
95that follow the
96.Fa ttinfo
97structure(s) in the file.
98.Pp
99Then there are
100.Fa tzh_leapcnt
101pairs of four-byte values, written in standard byte order;
102the first value of each pair gives the time
103.Pq as returned by Xr time 3
104at which a leap second occurs;
105the second gives the
106.Em total
107number of leap seconds to be applied after the given time.
108The pairs of values are sorted in ascending order by time.
109.Pp
110Then there are
111.Fa tzh_ttisstdcnt
112standard/wall indicators, each stored as a one-byte value;
113they tell whether the transition times associated with local time types
114were specified as standard time or wall clock time,
115and are used when a time zone file is used in handling POSIX-style
116time zone environment variables.
117.Pp
118Finally there are
119.Fa tzh_ttisgmtcnt
120UTC/local indicators, each stored as a one-byte value;
121they tell whether the transition times associated with local time types
122were specified as UTC or local time,
123and are used when a time zone file is used in handling POSIX-style
124time zone environment variables.
125.Pp
126.Xr localtime 3
127uses the first standard-time
128.Fa ttinfo
129structure in the file,
130or simply the first
131.Fa ttinfo
132structure in the absence of a standard-time structure,
133if either
134.Fa tzh_timecnt
135is zero or the time argument is less than the first transition time recorded
136in the file.
137.Sh SEE ALSO
138.Xr ctime 3
139.\" @(#)tzfile.5	7.11
140.\" This file is in the public domain, so clarified as of
141.\" 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
142