michael@0: #ifndef TZFILE_H michael@0: michael@0: #define TZFILE_H michael@0: michael@0: /* michael@0: ** This file is in the public domain, so clarified as of michael@0: ** 1996-06-05 by Arthur David Olson. michael@0: */ michael@0: michael@0: /* michael@0: ** This header is for use ONLY with the time conversion code. michael@0: ** There is no guarantee that it will remain unchanged, michael@0: ** or that it will remain at all. michael@0: ** Do NOT copy it to any system include directory. michael@0: ** Thank you! michael@0: */ michael@0: michael@0: /* michael@0: ** ID michael@0: */ michael@0: michael@0: #ifndef lint michael@0: #ifndef NOID michael@0: static char tzfilehid[] = "@(#)tzfile.h 8.1"; michael@0: #endif /* !defined NOID */ michael@0: #endif /* !defined lint */ michael@0: michael@0: /* michael@0: ** Information about time zone files. michael@0: */ michael@0: michael@0: #ifndef TZDIR michael@0: #define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */ michael@0: #endif /* !defined TZDIR */ michael@0: michael@0: #ifndef TZDEFAULT michael@0: #define TZDEFAULT "localtime" michael@0: #endif /* !defined TZDEFAULT */ michael@0: michael@0: #ifndef TZDEFRULES michael@0: #define TZDEFRULES "posixrules" michael@0: #endif /* !defined TZDEFRULES */ michael@0: michael@0: /* michael@0: ** Each file begins with. . . michael@0: */ michael@0: michael@0: #define TZ_MAGIC "TZif" michael@0: michael@0: struct tzhead { michael@0: char tzh_magic[4]; /* TZ_MAGIC */ michael@0: char tzh_version[1]; /* '\0' or '2' as of 2005 */ michael@0: char tzh_reserved[15]; /* reserved--must be zero */ michael@0: char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ michael@0: char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ michael@0: char tzh_leapcnt[4]; /* coded number of leap seconds */ michael@0: char tzh_timecnt[4]; /* coded number of transition times */ michael@0: char tzh_typecnt[4]; /* coded number of local time types */ michael@0: char tzh_charcnt[4]; /* coded number of abbr. chars */ michael@0: }; michael@0: michael@0: /* michael@0: ** . . .followed by. . . michael@0: ** michael@0: ** tzh_timecnt (char [4])s coded transition times a la time(2) michael@0: ** tzh_timecnt (unsigned char)s types of local time starting at above michael@0: ** tzh_typecnt repetitions of michael@0: ** one (char [4]) coded UTC offset in seconds michael@0: ** one (unsigned char) used to set tm_isdst michael@0: ** one (unsigned char) that's an abbreviation list index michael@0: ** tzh_charcnt (char)s '\0'-terminated zone abbreviations michael@0: ** tzh_leapcnt repetitions of michael@0: ** one (char [4]) coded leap second transition times michael@0: ** one (char [4]) total correction after above michael@0: ** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition michael@0: ** time is standard time, if FALSE, michael@0: ** transition time is wall clock time michael@0: ** if absent, transition times are michael@0: ** assumed to be wall clock time michael@0: ** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition michael@0: ** time is UTC, if FALSE, michael@0: ** transition time is local time michael@0: ** if absent, transition times are michael@0: ** assumed to be local time michael@0: */ michael@0: michael@0: /* michael@0: ** If tzh_version is '2' or greater, the above is followed by a second instance michael@0: ** of tzhead and a second instance of the data in which each coded transition michael@0: ** time uses 8 rather than 4 chars, michael@0: ** then a POSIX-TZ-environment-variable-style string for use in handling michael@0: ** instants after the last transition time stored in the file michael@0: ** (with nothing between the newlines if there is no POSIX representation for michael@0: ** such instants). michael@0: */ michael@0: michael@0: /* michael@0: ** In the current implementation, "tzset()" refuses to deal with files that michael@0: ** exceed any of the limits below. michael@0: */ michael@0: michael@0: #ifndef TZ_MAX_TIMES michael@0: #define TZ_MAX_TIMES 1200 michael@0: #endif /* !defined TZ_MAX_TIMES */ michael@0: michael@0: #ifndef TZ_MAX_TYPES michael@0: #ifndef NOSOLAR michael@0: #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ michael@0: #endif /* !defined NOSOLAR */ michael@0: #ifdef NOSOLAR michael@0: /* michael@0: ** Must be at least 14 for Europe/Riga as of Jan 12 1995, michael@0: ** as noted by Earl Chew. michael@0: */ michael@0: #define TZ_MAX_TYPES 20 /* Maximum number of local time types */ michael@0: #endif /* !defined NOSOLAR */ michael@0: #endif /* !defined TZ_MAX_TYPES */ michael@0: michael@0: #ifndef TZ_MAX_CHARS michael@0: #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ michael@0: /* (limited by what unsigned chars can hold) */ michael@0: #endif /* !defined TZ_MAX_CHARS */ michael@0: michael@0: #ifndef TZ_MAX_LEAPS michael@0: #define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ michael@0: #endif /* !defined TZ_MAX_LEAPS */ michael@0: michael@0: #define SECSPERMIN 60 michael@0: #define MINSPERHOUR 60 michael@0: #define HOURSPERDAY 24 michael@0: #define DAYSPERWEEK 7 michael@0: #define DAYSPERNYEAR 365 michael@0: #define DAYSPERLYEAR 366 michael@0: #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) michael@0: #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) michael@0: #define MONSPERYEAR 12 michael@0: michael@0: #define TM_SUNDAY 0 michael@0: #define TM_MONDAY 1 michael@0: #define TM_TUESDAY 2 michael@0: #define TM_WEDNESDAY 3 michael@0: #define TM_THURSDAY 4 michael@0: #define TM_FRIDAY 5 michael@0: #define TM_SATURDAY 6 michael@0: michael@0: #define TM_JANUARY 0 michael@0: #define TM_FEBRUARY 1 michael@0: #define TM_MARCH 2 michael@0: #define TM_APRIL 3 michael@0: #define TM_MAY 4 michael@0: #define TM_JUNE 5 michael@0: #define TM_JULY 6 michael@0: #define TM_AUGUST 7 michael@0: #define TM_SEPTEMBER 8 michael@0: #define TM_OCTOBER 9 michael@0: #define TM_NOVEMBER 10 michael@0: #define TM_DECEMBER 11 michael@0: michael@0: #define TM_YEAR_BASE 1900 michael@0: michael@0: #define EPOCH_YEAR 1970 michael@0: #define EPOCH_WDAY TM_THURSDAY michael@0: michael@0: #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) michael@0: michael@0: /* michael@0: ** Since everything in isleap is modulo 400 (or a factor of 400), we know that michael@0: ** isleap(y) == isleap(y % 400) michael@0: ** and so michael@0: ** isleap(a + b) == isleap((a + b) % 400) michael@0: ** or michael@0: ** isleap(a + b) == isleap(a % 400 + b % 400) michael@0: ** This is true even if % means modulo rather than Fortran remainder michael@0: ** (which is allowed by C89 but not C99). michael@0: ** We use this to avoid addition overflow problems. michael@0: */ michael@0: michael@0: #define isleap_sum(a, b) isleap((a) % 400 + (b) % 400) michael@0: michael@0: #endif /* !defined TZFILE_H */