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