xref: /titanic_50/usr/src/uts/common/sys/tzfile.h (revision e5dcf7beb7c949f9234713d5818b581ec3825443)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  *	from Arthur Olson's 6.1
28  */
29 
30 #ifndef _SYS_TZFILE_H
31 #define	_SYS_TZFILE_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Information about time zone files.
41  */
42 
43 #define	TZDIR	"/usr/share/lib/zoneinfo" /* Time zone object file directory */
44 
45 #define	TZDEFAULT	(getenv("TZ"))
46 
47 #define	TZDEFRULES	"posixrules"
48 
49 /*
50  * Each file begins with. . .
51  */
52 
53 struct tzhead {
54 	char	tzh_reserved[24];	/* reserved for future use */
55 	char	tzh_ttisstdcnt[4];	/* coded number of trans. time flags */
56 	char	tzh_leapcnt[4];		/* coded number of leap seconds */
57 	char	tzh_timecnt[4];		/* coded number of transition times */
58 	char	tzh_typecnt[4];		/* coded number of local time types */
59 	char	tzh_charcnt[4];		/* coded number of abbr. chars */
60 };
61 
62 /*
63  * . . .followed by. . .
64  *
65  *	tzh_timecnt (char [4])s		coded transition times a la time(2)
66  *	tzh_timecnt (unsigned char)s	types of local time starting at above
67  *	tzh_typecnt repetitions of
68  *		one (char [4])		coded GMT offset in seconds
69  *		one (unsigned char)	used to set tm_isdst
70  *		one (unsigned char)	that's an abbreviation list index
71  *	tzh_charcnt (char)s		'\0'-terminated zone abbreviations
72  *	tzh_leapcnt repetitions of
73  *		one (char [4])		coded leap second transition times
74  *		one (char [4])		total correction after above
75  *	tzh_ttisstdcnt (char)s		indexed by type; if TRUE, transition
76  *					time is standard time, if FALSE,
77  *					transition time is wall clock time
78  *					if absent, transition times are
79  *					assumed to be wall clock time
80  */
81 
82 /*
83  * In the current implementation, "tzset()" refuses to deal with files that
84  * exceed any of the limits below.
85  */
86 
87 /*
88  * The TZ_MAX_TIMES value below is enough to handle a bit more than a
89  * year's worth of solar time (corrected daily to the nearest second) or
90  * 138 years of Pacific Presidential Election time
91  * (where there are three time zone transitions every fourth year).
92  */
93 #define	TZ_MAX_TIMES	370
94 
95 #define	TZ_MAX_TYPES	256	/* Limited by what (unsigned char)'s can hold */
96 
97 #define	TZ_MAX_CHARS	50	/* Maximum number of abbreviation characters */
98 
99 #define	TZ_MAX_LEAPS	50	/* Maximum number of leap second corrections */
100 
101 #define	SECSPERMIN	60
102 #define	MINSPERHOUR	60
103 #define	HOURSPERDAY	24
104 #define	DAYSPERWEEK	7
105 #define	DAYSPERNYEAR	365
106 #define	DAYSPERLYEAR	366
107 #define	SECSPERHOUR	(SECSPERMIN * MINSPERHOUR)
108 #define	SECSPERDAY	((long)SECSPERHOUR * HOURSPERDAY)
109 #define	MONSPERYEAR	12
110 
111 #define	TM_SUNDAY	0
112 #define	TM_MONDAY	1
113 #define	TM_TUESDAY	2
114 #define	TM_WEDNESDAY	3
115 #define	TM_THURSDAY	4
116 #define	TM_FRIDAY	5
117 #define	TM_SATURDAY	6
118 
119 #define	TM_JANUARY	0
120 #define	TM_FEBRUARY	1
121 #define	TM_MARCH	2
122 #define	TM_APRIL	3
123 #define	TM_MAY		4
124 #define	TM_JUNE		5
125 #define	TM_JULY		6
126 #define	TM_AUGUST	7
127 #define	TM_SEPTEMBER	8
128 #define	TM_OCTOBER	9
129 #define	TM_NOVEMBER	10
130 #define	TM_DECEMBER	11
131 
132 #define	TM_YEAR_BASE	1900
133 
134 #define	EPOCH_YEAR	1970
135 #define	EPOCH_WDAY	TM_THURSDAY
136 
137 /*
138  * Accurate only for the past couple of centuries;
139  * that will probably do.
140  */
141 
142 #define	isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
143 
144 /*
145  * Use of the underscored variants may cause problems if you move your code to
146  * certain System-V-based systems; for maximum portability, use the
147  * underscore-free variants.  The underscored variants are provided for
148  * backward compatibility only; they may disappear from future versions of
149  * this file.
150  */
151 
152 #define	SECS_PER_MIN	SECSPERMIN
153 #define	MINS_PER_HOUR	MINSPERHOUR
154 #define	HOURS_PER_DAY	HOURSPERDAY
155 #define	DAYS_PER_WEEK	DAYSPERWEEK
156 #define	DAYS_PER_NYEAR	DAYSPERNYEAR
157 #define	DAYS_PER_LYEAR	DAYSPERLYEAR
158 #define	SECS_PER_HOUR	SECSPERHOUR
159 #define	SECS_PER_DAY	SECSPERDAY
160 #define	MONS_PER_YEAR	MONSPERYEAR
161 
162 #ifdef	__cplusplus
163 }
164 #endif
165 
166 #endif /* _SYS_TZFILE_H */
167