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