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