My Project
tzfile.h
00001 #ifndef TZFILE_INCLUDED
00002 #define TZFILE_INCLUDED
00003 
00004 /* Copyright (c) 2004, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc.
00005    Use is subject to license terms.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; version 2 of the License.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software Foundation,
00018    51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
00019 
00020 /* 
00021    This file is based on public domain code from ftp://elsie.ncih.nist.gov/
00022    Initial source code is in the public domain, so clarified as of
00023    1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). 
00024 */
00025 
00026 /*
00027   Information about time zone files.
00028 */
00029 
00030 #ifndef TZDIR
00031 #define TZDIR   "/usr/share/zoneinfo" /* Time zone object file directory */
00032 #endif /* !defined TZDIR */
00033 
00034 /*
00035   Each file begins with. . .
00036 */
00037 
00038 #define TZ_MAGIC        "TZif"
00039 
00040 struct tzhead {
00041         uchar   tzh_magic[4];           /* TZ_MAGIC */
00042         uchar   tzh_reserved[16];       /* reserved for future use */
00043         uchar   tzh_ttisgmtcnt[4];      /* coded number of trans. time flags */
00044         uchar   tzh_ttisstdcnt[4];      /* coded number of trans. time flags */
00045         uchar   tzh_leapcnt[4];         /* coded number of leap seconds */
00046         uchar   tzh_timecnt[4];         /* coded number of transition times */
00047         uchar   tzh_typecnt[4];         /* coded number of local time types */
00048         uchar   tzh_charcnt[4];         /* coded number of abbr. chars */
00049 };
00050 
00051 /*
00052   . . .followed by. . .
00053   
00054   tzh_timecnt (char [4])s               coded transition times a la time(2)
00055   tzh_timecnt (unsigned char)s          types of local time starting at above
00056   tzh_typecnt repetitions of
00057     one (char [4])                      coded UTC offset in seconds
00058     one (unsigned char)                 used to set tm_isdst
00059     one (unsigned char)                 that's an abbreviation list index
00060   tzh_charcnt (char)s                   '\0'-terminated zone abbreviations
00061   tzh_leapcnt repetitions of
00062     one (char [4])                      coded leap second transition times
00063     one (char [4])                      total correction after above
00064   tzh_ttisstdcnt (char)s                indexed by type; if TRUE, transition
00065                                         time is standard time, if FALSE,
00066                                         transition time is wall clock time
00067                                         if absent, transition times are
00068                                         assumed to be wall clock time
00069   tzh_ttisgmtcnt (char)s                indexed by type; if TRUE, transition
00070                                         time is UTC, if FALSE,
00071                                         transition time is local time
00072                                         if absent, transition times are
00073                                         assumed to be local time
00074 */
00075 
00076 /*
00077   In the current implementation, we refuse to deal with files that
00078   exceed any of the limits below.
00079 */
00080 
00081 #ifndef TZ_MAX_TIMES
00082 /*
00083   The TZ_MAX_TIMES value below is enough to handle a bit more than a
00084   year's worth of solar time (corrected daily to the nearest second) or
00085   138 years of Pacific Presidential Election time
00086   (where there are three time zone transitions every fourth year).
00087 */
00088 #define TZ_MAX_TIMES    370
00089 #endif /* !defined TZ_MAX_TIMES */
00090 
00091 #ifndef TZ_MAX_TYPES
00092 #ifdef SOLAR
00093 #define TZ_MAX_TYPES    256 /* Limited by what (unsigned char)'s can hold */
00094 #else
00095 /*
00096   Must be at least 14 for Europe/Riga as of Jan 12 1995,
00097   as noted by Earl Chew <earl@hpato.aus.hp.com>.
00098 */
00099 #define TZ_MAX_TYPES    20      /* Maximum number of local time types */
00100 #endif /* defined SOLAR */
00101 #endif /* !defined TZ_MAX_TYPES */
00102 
00103 #ifndef TZ_MAX_CHARS
00104 #define TZ_MAX_CHARS    50      /* Maximum number of abbreviation characters */
00105                                 /* (limited by what unsigned chars can hold) */
00106 #endif /* !defined TZ_MAX_CHARS */
00107 
00108 #ifndef TZ_MAX_LEAPS
00109 #define TZ_MAX_LEAPS    50      /* Maximum number of leap second corrections */
00110 #endif /* !defined TZ_MAX_LEAPS */
00111 
00112 #ifndef TZ_MAX_REV_RANGES
00113 #ifdef SOLAR
00114 /* Solar (Asia/RiyadhXX) zones need significantly bigger TZ_MAX_REV_RANGES */
00115 #define TZ_MAX_REV_RANGES (TZ_MAX_TIMES*2+TZ_MAX_LEAPS*2+2)
00116 #else
00117 #define TZ_MAX_REV_RANGES (TZ_MAX_TIMES+TZ_MAX_LEAPS+2)
00118 #endif
00119 #endif
00120 
00121 #define SECS_PER_MIN    60
00122 #define MINS_PER_HOUR   60
00123 #define HOURS_PER_DAY   24
00124 #define DAYS_PER_WEEK   7
00125 #define DAYS_PER_NYEAR  365
00126 #define DAYS_PER_LYEAR  366
00127 #define SECS_PER_HOUR   (SECS_PER_MIN * MINS_PER_HOUR)
00128 #define SECS_PER_DAY    ((long) SECS_PER_HOUR * HOURS_PER_DAY)
00129 #define MONS_PER_YEAR   12
00130 
00131 #define TM_YEAR_BASE    1900
00132 
00133 #define EPOCH_YEAR      1970
00134 
00135 /*
00136   Accurate only for the past couple of centuries,
00137   that will probably do.
00138 */
00139 
00140 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
00141 
00142 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines