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