]> git.saurik.com Git - apple/libc.git/blob - include/tzfile.h
Libc-320.tar.gz
[apple/libc.git] / include / tzfile.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Copyright (c) 1988, 1993
27 * The Regents of the University of California. All rights reserved.
28 *
29 * This code is derived from software contributed to Berkeley by
30 * Arthur David Olson of the National Cancer Institute.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)tzfile.h 8.1 (Berkeley) 6/2/93
61 */
62
63 #ifndef _TZFILE_H_
64 #define _TZFILE_H_
65
66 /*
67 * Information about time zone files.
68 */
69 /* Time zone object file directory */
70 #define TZDIR "/usr/share/zoneinfo"
71 #define TZDEFAULT "/etc/localtime"
72 #define TZDEFRULES "posixrules"
73
74 /*
75 ** Each file begins with. . .
76 */
77
78 struct tzhead {
79 char tzh_reserved[24]; /* reserved for future use */
80 char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
81 char tzh_leapcnt[4]; /* coded number of leap seconds */
82 char tzh_timecnt[4]; /* coded number of transition times */
83 char tzh_typecnt[4]; /* coded number of local time types */
84 char tzh_charcnt[4]; /* coded number of abbr. chars */
85 };
86
87 /*
88 ** . . .followed by. . .
89 **
90 ** tzh_timecnt (char [4])s coded transition times a la time(2)
91 ** tzh_timecnt (unsigned char)s types of local time starting at above
92 ** tzh_typecnt repetitions of
93 ** one (char [4]) coded GMT offset in seconds
94 ** one (unsigned char) used to set tm_isdst
95 ** one (unsigned char) that's an abbreviation list index
96 ** tzh_charcnt (char)s '\0'-terminated zone abbreviations
97 ** tzh_leapcnt repetitions of
98 ** one (char [4]) coded leap second transition times
99 ** one (char [4]) total correction after above
100 ** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
101 ** time is standard time, if FALSE,
102 ** transition time is wall clock time
103 ** if absent, transition times are
104 ** assumed to be wall clock time
105 */
106
107 /*
108 ** In the current implementation, "tzset()" refuses to deal with files that
109 ** exceed any of the limits below.
110 */
111
112 /*
113 ** The TZ_MAX_TIMES value below is enough to handle a bit more than a
114 ** year's worth of solar time (corrected daily to the nearest second) or
115 ** 138 years of Pacific Presidential Election time
116 ** (where there are three time zone transitions every fourth year).
117 */
118 #define TZ_MAX_TIMES 370
119
120 #define NOSOLAR /* 4BSD doesn't currently handle solar time */
121
122 #ifndef NOSOLAR
123 #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
124 #else
125 #define TZ_MAX_TYPES 20 /* Maximum number of local time types */
126 #endif
127
128 #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
129
130 #define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
131
132 #define SECSPERMIN 60
133 #define MINSPERHOUR 60
134 #define HOURSPERDAY 24
135 #define DAYSPERWEEK 7
136 #define DAYSPERNYEAR 365
137 #define DAYSPERLYEAR 366
138 #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
139 #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
140 #define MONSPERYEAR 12
141
142 #define TM_SUNDAY 0
143 #define TM_MONDAY 1
144 #define TM_TUESDAY 2
145 #define TM_WEDNESDAY 3
146 #define TM_THURSDAY 4
147 #define TM_FRIDAY 5
148 #define TM_SATURDAY 6
149
150 #define TM_JANUARY 0
151 #define TM_FEBRUARY 1
152 #define TM_MARCH 2
153 #define TM_APRIL 3
154 #define TM_MAY 4
155 #define TM_JUNE 5
156 #define TM_JULY 6
157 #define TM_AUGUST 7
158 #define TM_SEPTEMBER 8
159 #define TM_OCTOBER 9
160 #define TM_NOVEMBER 10
161 #define TM_DECEMBER 11
162
163 #define TM_YEAR_BASE 1900
164
165 #define EPOCH_YEAR 1970
166 #define EPOCH_WDAY TM_THURSDAY
167
168 /*
169 ** Accurate only for the past couple of centuries;
170 ** that will probably do.
171 */
172
173 #define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
174
175 #endif /* !_TZFILE_H_ */