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