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