xref: /freebsd/contrib/tzcode/tzfile.h (revision bc42155199b5b0b479311e05b07aee7f6f9c5172)
1*bc421551SDag-Erling Smørgrav /* Layout and location of TZif files.  */
2*bc421551SDag-Erling Smørgrav 
3*bc421551SDag-Erling Smørgrav #ifndef TZFILE_H
4*bc421551SDag-Erling Smørgrav #define TZFILE_H
5*bc421551SDag-Erling Smørgrav 
6*bc421551SDag-Erling Smørgrav 
7*bc421551SDag-Erling Smørgrav /*
8*bc421551SDag-Erling Smørgrav ** This file is in the public domain, so clarified as of
9*bc421551SDag-Erling Smørgrav ** 1996-06-05 by Arthur David Olson.
10*bc421551SDag-Erling Smørgrav **
11*bc421551SDag-Erling Smørgrav ** $FreeBSD$
12*bc421551SDag-Erling Smørgrav */
13*bc421551SDag-Erling Smørgrav 
14*bc421551SDag-Erling Smørgrav /*
15*bc421551SDag-Erling Smørgrav ** This header is for use ONLY with the time conversion code.
16*bc421551SDag-Erling Smørgrav ** There is no guarantee that it will remain unchanged,
17*bc421551SDag-Erling Smørgrav ** or that it will remain at all.
18*bc421551SDag-Erling Smørgrav ** Do NOT copy it to any system include directory.
19*bc421551SDag-Erling Smørgrav ** Thank you!
20*bc421551SDag-Erling Smørgrav */
21*bc421551SDag-Erling Smørgrav 
22*bc421551SDag-Erling Smørgrav /*
23*bc421551SDag-Erling Smørgrav ** Information about time zone files.
24*bc421551SDag-Erling Smørgrav */
25*bc421551SDag-Erling Smørgrav 
26*bc421551SDag-Erling Smørgrav #ifndef TZDIR
27*bc421551SDag-Erling Smørgrav # define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */
28*bc421551SDag-Erling Smørgrav #endif /* !defined TZDIR */
29*bc421551SDag-Erling Smørgrav 
30*bc421551SDag-Erling Smørgrav #ifndef TZDEFAULT
31*bc421551SDag-Erling Smørgrav # define TZDEFAULT "/etc/localtime"
32*bc421551SDag-Erling Smørgrav #endif /* !defined TZDEFAULT */
33*bc421551SDag-Erling Smørgrav 
34*bc421551SDag-Erling Smørgrav #ifndef TZDEFRULES
35*bc421551SDag-Erling Smørgrav # define TZDEFRULES "posixrules"
36*bc421551SDag-Erling Smørgrav #endif /* !defined TZDEFRULES */
37*bc421551SDag-Erling Smørgrav 
38*bc421551SDag-Erling Smørgrav 
39*bc421551SDag-Erling Smørgrav /* See Internet RFC 8536 for more details about the following format.  */
40*bc421551SDag-Erling Smørgrav 
41*bc421551SDag-Erling Smørgrav /*
42*bc421551SDag-Erling Smørgrav ** Each file begins with. . .
43*bc421551SDag-Erling Smørgrav */
44*bc421551SDag-Erling Smørgrav 
45*bc421551SDag-Erling Smørgrav #define	TZ_MAGIC	"TZif"
46*bc421551SDag-Erling Smørgrav 
47*bc421551SDag-Erling Smørgrav struct tzhead {
48*bc421551SDag-Erling Smørgrav 	char	tzh_magic[4];		/* TZ_MAGIC */
49*bc421551SDag-Erling Smørgrav 	char	tzh_version[1];		/* '\0' or '2'-'4' as of 2021 */
50*bc421551SDag-Erling Smørgrav 	char	tzh_reserved[15];	/* reserved; must be zero */
51*bc421551SDag-Erling Smørgrav 	char	tzh_ttisutcnt[4];	/* coded number of trans. time flags */
52*bc421551SDag-Erling Smørgrav 	char	tzh_ttisstdcnt[4];	/* coded number of trans. time flags */
53*bc421551SDag-Erling Smørgrav 	char	tzh_leapcnt[4];		/* coded number of leap seconds */
54*bc421551SDag-Erling Smørgrav 	char	tzh_timecnt[4];		/* coded number of transition times */
55*bc421551SDag-Erling Smørgrav 	char	tzh_typecnt[4];		/* coded number of local time types */
56*bc421551SDag-Erling Smørgrav 	char	tzh_charcnt[4];		/* coded number of abbr. chars */
57*bc421551SDag-Erling Smørgrav };
58*bc421551SDag-Erling Smørgrav 
59*bc421551SDag-Erling Smørgrav /*
60*bc421551SDag-Erling Smørgrav ** . . .followed by. . .
61*bc421551SDag-Erling Smørgrav **
62*bc421551SDag-Erling Smørgrav **	tzh_timecnt (char [4])s		coded transition times a la time(2)
63*bc421551SDag-Erling Smørgrav **	tzh_timecnt (unsigned char)s	types of local time starting at above
64*bc421551SDag-Erling Smørgrav **	tzh_typecnt repetitions of
65*bc421551SDag-Erling Smørgrav **		one (char [4])		coded UT offset in seconds
66*bc421551SDag-Erling Smørgrav **		one (unsigned char)	used to set tm_isdst
67*bc421551SDag-Erling Smørgrav **		one (unsigned char)	that's an abbreviation list index
68*bc421551SDag-Erling Smørgrav **	tzh_charcnt (char)s		'\0'-terminated zone abbreviations
69*bc421551SDag-Erling Smørgrav **	tzh_leapcnt repetitions of
70*bc421551SDag-Erling Smørgrav **		one (char [4])		coded leap second transition times
71*bc421551SDag-Erling Smørgrav **		one (char [4])		total correction after above
72*bc421551SDag-Erling Smørgrav **	tzh_ttisstdcnt (char)s		indexed by type; if 1, transition
73*bc421551SDag-Erling Smørgrav **					time is standard time, if 0,
74*bc421551SDag-Erling Smørgrav **					transition time is local (wall clock)
75*bc421551SDag-Erling Smørgrav **					time; if absent, transition times are
76*bc421551SDag-Erling Smørgrav **					assumed to be local time
77*bc421551SDag-Erling Smørgrav **	tzh_ttisutcnt (char)s		indexed by type; if 1, transition
78*bc421551SDag-Erling Smørgrav **					time is UT, if 0, transition time is
79*bc421551SDag-Erling Smørgrav **					local time; if absent, transition
80*bc421551SDag-Erling Smørgrav **					times are assumed to be local time.
81*bc421551SDag-Erling Smørgrav **					When this is 1, the corresponding
82*bc421551SDag-Erling Smørgrav **					std/wall indicator must also be 1.
83*bc421551SDag-Erling Smørgrav */
84*bc421551SDag-Erling Smørgrav 
85*bc421551SDag-Erling Smørgrav /*
86*bc421551SDag-Erling Smørgrav ** If tzh_version is '2' or greater, the above is followed by a second instance
87*bc421551SDag-Erling Smørgrav ** of tzhead and a second instance of the data in which each coded transition
88*bc421551SDag-Erling Smørgrav ** time uses 8 rather than 4 chars,
89*bc421551SDag-Erling Smørgrav ** then a POSIX-TZ-environment-variable-style string for use in handling
90*bc421551SDag-Erling Smørgrav ** instants after the last transition time stored in the file
91*bc421551SDag-Erling Smørgrav ** (with nothing between the newlines if there is no POSIX representation for
92*bc421551SDag-Erling Smørgrav ** such instants).
93*bc421551SDag-Erling Smørgrav **
94*bc421551SDag-Erling Smørgrav ** If tz_version is '3' or greater, the above is extended as follows.
95*bc421551SDag-Erling Smørgrav ** First, the POSIX TZ string's hour offset may range from -167
96*bc421551SDag-Erling Smørgrav ** through 167 as compared to the POSIX-required 0 through 24.
97*bc421551SDag-Erling Smørgrav ** Second, its DST start time may be January 1 at 00:00 and its stop
98*bc421551SDag-Erling Smørgrav ** time December 31 at 24:00 plus the difference between DST and
99*bc421551SDag-Erling Smørgrav ** standard time, indicating DST all year.
100*bc421551SDag-Erling Smørgrav */
101*bc421551SDag-Erling Smørgrav 
102*bc421551SDag-Erling Smørgrav /*
103*bc421551SDag-Erling Smørgrav ** In the current implementation, "tzset()" refuses to deal with files that
104*bc421551SDag-Erling Smørgrav ** exceed any of the limits below.
105*bc421551SDag-Erling Smørgrav */
106*bc421551SDag-Erling Smørgrav 
107*bc421551SDag-Erling Smørgrav #ifndef TZ_MAX_TIMES
108*bc421551SDag-Erling Smørgrav # define TZ_MAX_TIMES 2000
109*bc421551SDag-Erling Smørgrav #endif /* !defined TZ_MAX_TIMES */
110*bc421551SDag-Erling Smørgrav 
111*bc421551SDag-Erling Smørgrav #ifndef TZ_MAX_TYPES
112*bc421551SDag-Erling Smørgrav /* This must be at least 17 for Europe/Samara and Europe/Vilnius.  */
113*bc421551SDag-Erling Smørgrav # define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
114*bc421551SDag-Erling Smørgrav #endif /* !defined TZ_MAX_TYPES */
115*bc421551SDag-Erling Smørgrav 
116*bc421551SDag-Erling Smørgrav #ifndef TZ_MAX_CHARS
117*bc421551SDag-Erling Smørgrav # define TZ_MAX_CHARS 50	/* Maximum number of abbreviation characters */
118*bc421551SDag-Erling Smørgrav 				/* (limited by what unsigned chars can hold) */
119*bc421551SDag-Erling Smørgrav #endif /* !defined TZ_MAX_CHARS */
120*bc421551SDag-Erling Smørgrav 
121*bc421551SDag-Erling Smørgrav #ifndef TZ_MAX_LEAPS
122*bc421551SDag-Erling Smørgrav # define TZ_MAX_LEAPS 50	/* Maximum number of leap second corrections */
123*bc421551SDag-Erling Smørgrav #endif /* !defined TZ_MAX_LEAPS */
124*bc421551SDag-Erling Smørgrav 
125*bc421551SDag-Erling Smørgrav #endif /* !defined TZFILE_H */
126