Header And Logo

PostgreSQL
| The world's most advanced open source database.

tzfile.h

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