intl/icu/source/tools/tzcode/tzfile.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 #ifndef TZFILE_H
michael@0 2
michael@0 3 #define TZFILE_H
michael@0 4
michael@0 5 /*
michael@0 6 ** This file is in the public domain, so clarified as of
michael@0 7 ** 1996-06-05 by Arthur David Olson.
michael@0 8 */
michael@0 9
michael@0 10 /*
michael@0 11 ** This header is for use ONLY with the time conversion code.
michael@0 12 ** There is no guarantee that it will remain unchanged,
michael@0 13 ** or that it will remain at all.
michael@0 14 ** Do NOT copy it to any system include directory.
michael@0 15 ** Thank you!
michael@0 16 */
michael@0 17
michael@0 18 /*
michael@0 19 ** ID
michael@0 20 */
michael@0 21
michael@0 22 #ifndef lint
michael@0 23 #ifndef NOID
michael@0 24 static char tzfilehid[] = "@(#)tzfile.h 8.1";
michael@0 25 #endif /* !defined NOID */
michael@0 26 #endif /* !defined lint */
michael@0 27
michael@0 28 /*
michael@0 29 ** Information about time zone files.
michael@0 30 */
michael@0 31
michael@0 32 #ifndef TZDIR
michael@0 33 #define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */
michael@0 34 #endif /* !defined TZDIR */
michael@0 35
michael@0 36 #ifndef TZDEFAULT
michael@0 37 #define TZDEFAULT "localtime"
michael@0 38 #endif /* !defined TZDEFAULT */
michael@0 39
michael@0 40 #ifndef TZDEFRULES
michael@0 41 #define TZDEFRULES "posixrules"
michael@0 42 #endif /* !defined TZDEFRULES */
michael@0 43
michael@0 44 /*
michael@0 45 ** Each file begins with. . .
michael@0 46 */
michael@0 47
michael@0 48 #define TZ_MAGIC "TZif"
michael@0 49
michael@0 50 struct tzhead {
michael@0 51 char tzh_magic[4]; /* TZ_MAGIC */
michael@0 52 char tzh_version[1]; /* '\0' or '2' as of 2005 */
michael@0 53 char tzh_reserved[15]; /* reserved--must be zero */
michael@0 54 char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
michael@0 55 char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
michael@0 56 char tzh_leapcnt[4]; /* coded number of leap seconds */
michael@0 57 char tzh_timecnt[4]; /* coded number of transition times */
michael@0 58 char tzh_typecnt[4]; /* coded number of local time types */
michael@0 59 char tzh_charcnt[4]; /* coded number of abbr. chars */
michael@0 60 };
michael@0 61
michael@0 62 /*
michael@0 63 ** . . .followed by. . .
michael@0 64 **
michael@0 65 ** tzh_timecnt (char [4])s coded transition times a la time(2)
michael@0 66 ** tzh_timecnt (unsigned char)s types of local time starting at above
michael@0 67 ** tzh_typecnt repetitions of
michael@0 68 ** one (char [4]) coded UTC offset in seconds
michael@0 69 ** one (unsigned char) used to set tm_isdst
michael@0 70 ** one (unsigned char) that's an abbreviation list index
michael@0 71 ** tzh_charcnt (char)s '\0'-terminated zone abbreviations
michael@0 72 ** tzh_leapcnt repetitions of
michael@0 73 ** one (char [4]) coded leap second transition times
michael@0 74 ** one (char [4]) total correction after above
michael@0 75 ** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
michael@0 76 ** time is standard time, if FALSE,
michael@0 77 ** transition time is wall clock time
michael@0 78 ** if absent, transition times are
michael@0 79 ** assumed to be wall clock time
michael@0 80 ** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
michael@0 81 ** time is UTC, if FALSE,
michael@0 82 ** transition time is local time
michael@0 83 ** if absent, transition times are
michael@0 84 ** assumed to be local time
michael@0 85 */
michael@0 86
michael@0 87 /*
michael@0 88 ** If tzh_version is '2' or greater, the above is followed by a second instance
michael@0 89 ** of tzhead and a second instance of the data in which each coded transition
michael@0 90 ** time uses 8 rather than 4 chars,
michael@0 91 ** then a POSIX-TZ-environment-variable-style string for use in handling
michael@0 92 ** instants after the last transition time stored in the file
michael@0 93 ** (with nothing between the newlines if there is no POSIX representation for
michael@0 94 ** such instants).
michael@0 95 */
michael@0 96
michael@0 97 /*
michael@0 98 ** In the current implementation, "tzset()" refuses to deal with files that
michael@0 99 ** exceed any of the limits below.
michael@0 100 */
michael@0 101
michael@0 102 #ifndef TZ_MAX_TIMES
michael@0 103 #define TZ_MAX_TIMES 1200
michael@0 104 #endif /* !defined TZ_MAX_TIMES */
michael@0 105
michael@0 106 #ifndef TZ_MAX_TYPES
michael@0 107 #ifndef NOSOLAR
michael@0 108 #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
michael@0 109 #endif /* !defined NOSOLAR */
michael@0 110 #ifdef NOSOLAR
michael@0 111 /*
michael@0 112 ** Must be at least 14 for Europe/Riga as of Jan 12 1995,
michael@0 113 ** as noted by Earl Chew.
michael@0 114 */
michael@0 115 #define TZ_MAX_TYPES 20 /* Maximum number of local time types */
michael@0 116 #endif /* !defined NOSOLAR */
michael@0 117 #endif /* !defined TZ_MAX_TYPES */
michael@0 118
michael@0 119 #ifndef TZ_MAX_CHARS
michael@0 120 #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
michael@0 121 /* (limited by what unsigned chars can hold) */
michael@0 122 #endif /* !defined TZ_MAX_CHARS */
michael@0 123
michael@0 124 #ifndef TZ_MAX_LEAPS
michael@0 125 #define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
michael@0 126 #endif /* !defined TZ_MAX_LEAPS */
michael@0 127
michael@0 128 #define SECSPERMIN 60
michael@0 129 #define MINSPERHOUR 60
michael@0 130 #define HOURSPERDAY 24
michael@0 131 #define DAYSPERWEEK 7
michael@0 132 #define DAYSPERNYEAR 365
michael@0 133 #define DAYSPERLYEAR 366
michael@0 134 #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
michael@0 135 #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
michael@0 136 #define MONSPERYEAR 12
michael@0 137
michael@0 138 #define TM_SUNDAY 0
michael@0 139 #define TM_MONDAY 1
michael@0 140 #define TM_TUESDAY 2
michael@0 141 #define TM_WEDNESDAY 3
michael@0 142 #define TM_THURSDAY 4
michael@0 143 #define TM_FRIDAY 5
michael@0 144 #define TM_SATURDAY 6
michael@0 145
michael@0 146 #define TM_JANUARY 0
michael@0 147 #define TM_FEBRUARY 1
michael@0 148 #define TM_MARCH 2
michael@0 149 #define TM_APRIL 3
michael@0 150 #define TM_MAY 4
michael@0 151 #define TM_JUNE 5
michael@0 152 #define TM_JULY 6
michael@0 153 #define TM_AUGUST 7
michael@0 154 #define TM_SEPTEMBER 8
michael@0 155 #define TM_OCTOBER 9
michael@0 156 #define TM_NOVEMBER 10
michael@0 157 #define TM_DECEMBER 11
michael@0 158
michael@0 159 #define TM_YEAR_BASE 1900
michael@0 160
michael@0 161 #define EPOCH_YEAR 1970
michael@0 162 #define EPOCH_WDAY TM_THURSDAY
michael@0 163
michael@0 164 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
michael@0 165
michael@0 166 /*
michael@0 167 ** Since everything in isleap is modulo 400 (or a factor of 400), we know that
michael@0 168 ** isleap(y) == isleap(y % 400)
michael@0 169 ** and so
michael@0 170 ** isleap(a + b) == isleap((a + b) % 400)
michael@0 171 ** or
michael@0 172 ** isleap(a + b) == isleap(a % 400 + b % 400)
michael@0 173 ** This is true even if % means modulo rather than Fortran remainder
michael@0 174 ** (which is allowed by C89 but not C99).
michael@0 175 ** We use this to avoid addition overflow problems.
michael@0 176 */
michael@0 177
michael@0 178 #define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
michael@0 179
michael@0 180 #endif /* !defined TZFILE_H */

mercurial