Back to index

glibc  2.9
tzfile.h
Go to the documentation of this file.
00001 #ifndef TZFILE_H
00002 
00003 #define TZFILE_H
00004 
00005 /*
00006 ** This file is in the public domain, so clarified as of
00007 ** 1996-06-05 by Arthur David Olson.
00008 */
00009 
00010 /*
00011 ** This header is for use ONLY with the time conversion code.
00012 ** There is no guarantee that it will remain unchanged,
00013 ** or that it will remain at all.
00014 ** Do NOT copy it to any system include directory.
00015 ** Thank you!
00016 */
00017 
00018 /*
00019 ** ID
00020 */
00021 
00022 #ifndef lint
00023 #ifndef NOID
00024 static char   tzfilehid[] = "@(#)tzfile.h 8.1";
00025 #endif /* !defined NOID */
00026 #endif /* !defined lint */
00027 
00028 /*
00029 ** Information about time zone files.
00030 */
00031 
00032 #ifndef TZDIR
00033 #define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */
00034 #endif /* !defined TZDIR */
00035 
00036 #ifndef TZDEFAULT
00037 #define TZDEFAULT    "localtime"
00038 #endif /* !defined TZDEFAULT */
00039 
00040 #ifndef TZDEFRULES
00041 #define TZDEFRULES   "posixrules"
00042 #endif /* !defined TZDEFRULES */
00043 
00044 /*
00045 ** Each file begins with. . .
00046 */
00047 
00048 #define       TZ_MAGIC      "TZif"
00049 
00050 struct tzhead {
00051        char   tzh_magic[4];        /* TZ_MAGIC */
00052        char   tzh_version[1];             /* '\0' or '2' as of 2005 */
00053        char   tzh_reserved[15];    /* reserved--must be zero */
00054        char   tzh_ttisgmtcnt[4];   /* coded number of trans. time flags */
00055        char   tzh_ttisstdcnt[4];   /* coded number of trans. time flags */
00056        char   tzh_leapcnt[4];             /* coded number of leap seconds */
00057        char   tzh_timecnt[4];             /* coded number of transition times */
00058        char   tzh_typecnt[4];             /* coded number of local time types */
00059        char   tzh_charcnt[4];             /* coded number of abbr. chars */
00060 };
00061 
00062 /*
00063 ** . . .followed by. . .
00064 **
00065 **     tzh_timecnt (char [4])s            coded transition times a la time(2)
00066 **     tzh_timecnt (unsigned char)s       types of local time starting at above
00067 **     tzh_typecnt repetitions of
00068 **            one (char [4])              coded UTC offset in seconds
00069 **            one (unsigned char)  used to set tm_isdst
00070 **            one (unsigned char)  that's an abbreviation list index
00071 **     tzh_charcnt (char)s         '\0'-terminated zone abbreviations
00072 **     tzh_leapcnt repetitions of
00073 **            one (char [4])              coded leap second transition times
00074 **            one (char [4])              total correction after above
00075 **     tzh_ttisstdcnt (char)s             indexed by type; if TRUE, transition
00076 **                                 time is standard time, if FALSE,
00077 **                                 transition time is wall clock time
00078 **                                 if absent, transition times are
00079 **                                 assumed to be wall clock time
00080 **     tzh_ttisgmtcnt (char)s             indexed by type; if TRUE, transition
00081 **                                 time is UTC, if FALSE,
00082 **                                 transition time is local time
00083 **                                 if absent, transition times are
00084 **                                 assumed to be local time
00085 */
00086 
00087 /*
00088 ** If tzh_version is '2' or greater, the above is followed by a second instance
00089 ** of tzhead and a second instance of the data in which each coded transition
00090 ** time uses 8 rather than 4 chars,
00091 ** then a POSIX-TZ-environment-variable-style string for use in handling
00092 ** instants after the last transition time stored in the file
00093 ** (with nothing between the newlines if there is no POSIX representation for
00094 ** such instants).
00095 */
00096 
00097 /*
00098 ** In the current implementation, "tzset()" refuses to deal with files that
00099 ** exceed any of the limits below.
00100 */
00101 
00102 #ifndef TZ_MAX_TIMES
00103 #define TZ_MAX_TIMES 1200
00104 #endif /* !defined TZ_MAX_TIMES */
00105 
00106 #ifndef TZ_MAX_TYPES
00107 #ifndef NOSOLAR
00108 #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
00109 #endif /* !defined NOSOLAR */
00110 #ifdef NOSOLAR
00111 /*
00112 ** Must be at least 14 for Europe/Riga as of Jan 12 1995,
00113 ** as noted by Earl Chew.
00114 */
00115 #define TZ_MAX_TYPES 20     /* Maximum number of local time types */
00116 #endif /* !defined NOSOLAR */
00117 #endif /* !defined TZ_MAX_TYPES */
00118 
00119 #ifndef TZ_MAX_CHARS
00120 #define TZ_MAX_CHARS 50     /* Maximum number of abbreviation characters */
00121                             /* (limited by what unsigned chars can hold) */
00122 #endif /* !defined TZ_MAX_CHARS */
00123 
00124 #ifndef TZ_MAX_LEAPS
00125 #define TZ_MAX_LEAPS 50     /* Maximum number of leap second corrections */
00126 #endif /* !defined TZ_MAX_LEAPS */
00127 
00128 #define SECSPERMIN   60
00129 #define MINSPERHOUR  60
00130 #define HOURSPERDAY  24
00131 #define DAYSPERWEEK  7
00132 #define DAYSPERNYEAR 365
00133 #define DAYSPERLYEAR 366
00134 #define SECSPERHOUR  (SECSPERMIN * MINSPERHOUR)
00135 #define SECSPERDAY   ((long) SECSPERHOUR * HOURSPERDAY)
00136 #define MONSPERYEAR  12
00137 
00138 #define TM_SUNDAY    0
00139 #define TM_MONDAY    1
00140 #define TM_TUESDAY   2
00141 #define TM_WEDNESDAY 3
00142 #define TM_THURSDAY  4
00143 #define TM_FRIDAY    5
00144 #define TM_SATURDAY  6
00145 
00146 #define TM_JANUARY   0
00147 #define TM_FEBRUARY  1
00148 #define TM_MARCH     2
00149 #define TM_APRIL     3
00150 #define TM_MAY              4
00151 #define TM_JUNE             5
00152 #define TM_JULY             6
00153 #define TM_AUGUST    7
00154 #define TM_SEPTEMBER 8
00155 #define TM_OCTOBER   9
00156 #define TM_NOVEMBER  10
00157 #define TM_DECEMBER  11
00158 
00159 #define TM_YEAR_BASE 1900
00160 
00161 #define EPOCH_YEAR   1970
00162 #define EPOCH_WDAY   TM_THURSDAY
00163 
00164 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
00165 
00166 /*
00167 ** Since everything in isleap is modulo 400 (or a factor of 400), we know that
00168 **     isleap(y) == isleap(y % 400)
00169 ** and so
00170 **     isleap(a + b) == isleap((a + b) % 400)
00171 ** or
00172 **     isleap(a + b) == isleap(a % 400 + b % 400)
00173 ** This is true even if % means modulo rather than Fortran remainder
00174 ** (which is allowed by C89 but not C99).
00175 ** We use this to avoid addition overflow problems.
00176 */
00177 
00178 #define isleap_sum(a, b)    isleap((a) % 400 + (b) % 400)
00179 
00180 #endif /* !defined TZFILE_H */