xref: /titanic_44/usr/src/head/tzfile.h (revision 55553f719b521a0bb4deab6efc944cd30c1a56aa)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1988 AT&T	*/
27 /*	  All Rights Reserved	*/
28 
29 #ifndef _TZFILE_H
30 #define	_TZFILE_H
31 
32 #pragma ident	"%Z%%M%	%I%	%E% SMI"
33 
34 /*
35  * A part of this file comes from public domain source, so
36  * clarified as of June 5, 1996 by Arthur David Olson
37  */
38 
39 #include <sys/types.h>
40 
41 /*
42  * WARNING:
43  * The interfaces defined in this header file are for Sun private use only.
44  * The contents of this file are subject to change without notice for the
45  * future releases.
46  */
47 
48 /* For further information, see ctime(3C) and zic(1M) man pages. */
49 
50 /*
51  * This file is in the public domain, so clarified as of
52  * 1996-06-05 by Arthur David Olson.
53  */
54 
55 /*
56  * This header is for use ONLY with the time conversion code.
57  * There is no guarantee that it will remain unchanged,
58  * or that it will remain at all.
59  * Do NOT copy it to any system include directory.
60  * Thank you!
61  */
62 
63 /* static char	tzfilehid[] = "@(#)tzfile.h	7.18"; */
64 
65 /*
66  * Note: Despite warnings from the authors of this code, Solaris has
67  * placed this header file in the system include directory.  This was
68  * probably done in order to build both zic and zdump which are in
69  * separate source directories, but both use this file.
70  */
71 
72 #ifdef	__cplusplus
73 extern "C" {
74 #endif
75 
76 /*
77  * Information about time zone files.
78  */
79 
80 #ifndef TZDIR
81 #define	TZDIR	"/usr/share/lib/zoneinfo" /* Time zone object file directory */
82 #endif /* !defined TZDIR */
83 
84 #ifndef TZDEFAULT
85 #define	TZDEFAULT	"localtime"
86 #endif /* !defined TZDEFAULT */
87 
88 #ifndef TZDEFRULES
89 #define	TZDEFRULES	"posixrules"
90 #endif /* !defined TZDEFRULES */
91 
92 /*
93  * Each file begins with. . .
94  */
95 
96 #define	TZ_MAGIC	"TZif"
97 
98 struct tzhead {
99 	char	tzh_magic[4];		/* TZ_MAGIC */
100 	char	tzh_reserved[16];	/* reserved for future use */
101 	char	tzh_ttisgmtcnt[4];	/* coded number of trans. time flags */
102 	char	tzh_ttisstdcnt[4];	/* coded number of trans. time flags */
103 	char	tzh_leapcnt[4];		/* coded number of leap seconds */
104 	char	tzh_timecnt[4];		/* coded number of transition times */
105 	char	tzh_typecnt[4];		/* coded number of local time types */
106 	char	tzh_charcnt[4];		/* coded number of abbr. chars */
107 };
108 
109 /*
110  * . . .followed by. . .
111  *
112  *	tzh_timecnt (char [4])s		coded transition times a la time(2)
113  *	tzh_timecnt (unsigned char)s	types of local time starting at above
114  *	tzh_typecnt repetitions of
115  *		one (char [4])		coded UTC offset in seconds
116  *		one (unsigned char)	used to set tm_isdst
117  *		one (unsigned char)	that's an abbreviation list index
118  *	tzh_charcnt (char)s		'\0'-terminated zone abbreviations
119  *	tzh_leapcnt repetitions of
120  *		one (char [4])		coded leap second transition times
121  *		one (char [4])		total correction after above
122  *	tzh_ttisstdcnt (char)s		indexed by type; if TRUE, transition
123  *					time is standard time, if FALSE,
124  *					transition time is wall clock time
125  *					if absent, transition times are
126  *					assumed to be wall clock time
127  *	tzh_ttisgmtcnt (char)s		indexed by type; if TRUE, transition
128  *					time is UTC, if FALSE,
129  *					transition time is local time
130  *					if absent, transition times are
131  *					assumed to be local time
132  */
133 
134 /*
135  * In the current implementation, "tzset()" refuses to deal with files that
136  * exceed any of the limits below.
137  */
138 
139 #ifndef TZ_MAX_TIMES
140 /*
141  * The TZ_MAX_TIMES value below is enough to handle a bit more than a
142  * year's worth of solar time (corrected daily to the nearest second) or
143  * 138 years of Pacific Presidential Election time
144  * (where there are three time zone transitions every fourth year).
145  */
146 #define	TZ_MAX_TIMES	370
147 #endif /* !defined TZ_MAX_TIMES */
148 
149 #ifndef TZ_MAX_TYPES
150 #ifndef NOSOLAR
151 #define	TZ_MAX_TYPES	256 /* Limited by what (unsigned char)'s can hold */
152 #endif /* !defined NOSOLAR */
153 #ifdef NOSOLAR
154 /*
155  * Must be at least 14 for Europe/Riga as of Jan 12 1995,
156  * as noted by Earl Chew.
157  */
158 #define	TZ_MAX_TYPES	20	/* Maximum number of local time types */
159 #endif /* !defined NOSOLAR */
160 #endif /* !defined TZ_MAX_TYPES */
161 
162 #ifndef TZ_MAX_CHARS
163 #define	TZ_MAX_CHARS	50	/* Maximum number of abbreviation characters */
164 				/* (limited by what unsigned chars can hold) */
165 #endif /* !defined TZ_MAX_CHARS */
166 
167 #ifndef TZ_MAX_LEAPS
168 #define	TZ_MAX_LEAPS	50	/* Maximum number of leap second corrections */
169 #endif /* !defined TZ_MAX_LEAPS */
170 
171 #define	SECSPERMIN	60
172 #define	MINSPERHOUR	60
173 #define	HOURSPERDAY	24
174 #define	DAYSPERWEEK	7
175 #define	DAYSPERNYEAR	365
176 #define	DAYSPERLYEAR	366
177 #define	SECSPERHOUR	(SECSPERMIN * MINSPERHOUR)
178 #define	SECSPERDAY	((time_t)SECSPERHOUR * HOURSPERDAY)
179 #define	MONSPERYEAR	12
180 
181 #define	TM_SUNDAY	0
182 #define	TM_MONDAY	1
183 #define	TM_TUESDAY	2
184 #define	TM_WEDNESDAY	3
185 #define	TM_THURSDAY	4
186 #define	TM_FRIDAY	5
187 #define	TM_SATURDAY	6
188 
189 #define	TM_JANUARY	0
190 #define	TM_FEBRUARY	1
191 #define	TM_MARCH	2
192 #define	TM_APRIL	3
193 #define	TM_MAY		4
194 #define	TM_JUNE		5
195 #define	TM_JULY		6
196 #define	TM_AUGUST	7
197 #define	TM_SEPTEMBER	8
198 #define	TM_OCTOBER	9
199 #define	TM_NOVEMBER	10
200 #define	TM_DECEMBER	11
201 
202 #define	TM_YEAR_BASE	1900
203 
204 #define	EPOCH_YEAR	1970
205 #define	EPOCH_WDAY	TM_THURSDAY
206 
207 #define	isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
208 
209 #ifndef USG
210 
211 /*
212  * Use of the underscored variants may cause problems if you move your code to
213  * certain System-V-based systems; for maximum portability, use the
214  * underscore-free variants.  The underscored variants are provided for
215  * backward compatibility only; they may disappear from future versions of
216  * this file.
217  */
218 
219 #define	SECS_PER_MIN	SECSPERMIN
220 #define	MINS_PER_HOUR	MINSPERHOUR
221 #define	HOURS_PER_DAY	HOURSPERDAY
222 #define	DAYS_PER_WEEK	DAYSPERWEEK
223 #define	DAYS_PER_NYEAR	DAYSPERNYEAR
224 #define	DAYS_PER_LYEAR	DAYSPERLYEAR
225 #define	SECS_PER_HOUR	SECSPERHOUR
226 #define	SECS_PER_DAY	SECSPERDAY
227 #define	MONS_PER_YEAR	MONSPERYEAR
228 
229 #endif /* !defined USG */
230 
231 /*
232  * Since everything in isleap is modulo 400 (or a factor of 400), we know that
233  *	isleap(y) == isleap(y % 400)
234  * and so
235  *	isleap(a + b) == isleap((a + b) % 400)
236  * or
237  *	isleap(a + b) == isleap(a % 400 + b % 400)
238  * This is true even if % means modulo rather than Fortran remainder
239  * (which is allowed by C89 but not C99).
240  * We use this to avoid addition overflow problems.
241  */
242 
243 #define	isleap_sum(a, b)	isleap((a) % 400 + (b) % 400)
244 
245 #ifdef	__cplusplus
246 }
247 #endif
248 
249 #endif	/* _TZFILE_H */
250