1 /* Copyright (c) 2004, 2007 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
17 This file is based on public domain code from ftp://elsie.ncih.nist.gov/
18 Initial source code is in the public domain, so clarified as of
19 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
23 Information about time zone files.
27 #define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */
28 #endif /* !defined TZDIR */
31 Each file begins with. . .
34 #define TZ_MAGIC "TZif"
37 uchar tzh_magic
[4]; /* TZ_MAGIC */
38 uchar tzh_reserved
[16]; /* reserved for future use */
39 uchar tzh_ttisgmtcnt
[4]; /* coded number of trans. time flags */
40 uchar tzh_ttisstdcnt
[4]; /* coded number of trans. time flags */
41 uchar tzh_leapcnt
[4]; /* coded number of leap seconds */
42 uchar tzh_timecnt
[4]; /* coded number of transition times */
43 uchar tzh_typecnt
[4]; /* coded number of local time types */
44 uchar tzh_charcnt
[4]; /* coded number of abbr. chars */
50 tzh_timecnt (char [4])s coded transition times a la time(2)
51 tzh_timecnt (unsigned char)s types of local time starting at above
52 tzh_typecnt repetitions of
53 one (char [4]) coded UTC offset in seconds
54 one (unsigned char) used to set tm_isdst
55 one (unsigned char) that's an abbreviation list index
56 tzh_charcnt (char)s '\0'-terminated zone abbreviations
57 tzh_leapcnt repetitions of
58 one (char [4]) coded leap second transition times
59 one (char [4]) total correction after above
60 tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
61 time is standard time, if FALSE,
62 transition time is wall clock time
63 if absent, transition times are
64 assumed to be wall clock time
65 tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
66 time is UTC, if FALSE,
67 transition time is local time
68 if absent, transition times are
69 assumed to be local time
73 In the current implementation, we refuse to deal with files that
74 exceed any of the limits below.
79 The TZ_MAX_TIMES value below is enough to handle a bit more than a
80 year's worth of solar time (corrected daily to the nearest second) or
81 138 years of Pacific Presidential Election time
82 (where there are three time zone transitions every fourth year).
84 #define TZ_MAX_TIMES 370
85 #endif /* !defined TZ_MAX_TIMES */
89 #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
92 Must be at least 14 for Europe/Riga as of Jan 12 1995,
93 as noted by Earl Chew <earl@hpato.aus.hp.com>.
95 #define TZ_MAX_TYPES 20 /* Maximum number of local time types */
96 #endif /* defined SOLAR */
97 #endif /* !defined TZ_MAX_TYPES */
100 #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
101 /* (limited by what unsigned chars can hold) */
102 #endif /* !defined TZ_MAX_CHARS */
105 #define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
106 #endif /* !defined TZ_MAX_LEAPS */
108 #ifndef TZ_MAX_REV_RANGES
110 /* Solar (Asia/RiyadhXX) zones need significantly bigger TZ_MAX_REV_RANGES */
111 #define TZ_MAX_REV_RANGES (TZ_MAX_TIMES*2+TZ_MAX_LEAPS*2+2)
113 #define TZ_MAX_REV_RANGES (TZ_MAX_TIMES+TZ_MAX_LEAPS+2)
117 #define SECS_PER_MIN 60
118 #define MINS_PER_HOUR 60
119 #define HOURS_PER_DAY 24
120 #define DAYS_PER_WEEK 7
121 #define DAYS_PER_NYEAR 365
122 #define DAYS_PER_LYEAR 366
123 #define SECS_PER_HOUR (SECS_PER_MIN * MINS_PER_HOUR)
124 #define SECS_PER_DAY ((long) SECS_PER_HOUR * HOURS_PER_DAY)
125 #define MONS_PER_YEAR 12
127 #define TM_YEAR_BASE 1900
129 #define EPOCH_YEAR 1970
132 Accurate only for the past couple of centuries,
133 that will probably do.
136 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))