]> granicus.if.org Git - postgresql/blob - src/timezone/tzfile.h
Add Olson's public domain timezone library to src/timezone.
[postgresql] / src / timezone / tzfile.h
1 #ifndef TZFILE_H\r
2 \r
3 #define TZFILE_H\r
4 \r
5 /*\r
6 ** This file is in the public domain, so clarified as of\r
7 ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).\r
8 */\r
9 \r
10 /*\r
11 ** This header is for use ONLY with the time conversion code.\r
12 ** There is no guarantee that it will remain unchanged,\r
13 ** or that it will remain at all.\r
14 ** Do NOT copy it to any system include directory.\r
15 ** Thank you!\r
16 */\r
17 \r
18 /*\r
19 ** ID\r
20 */\r
21 \r
22 #ifndef lint\r
23 #ifndef NOID\r
24 static char     tzfilehid[] = "@(#)tzfile.h     7.14";\r
25 #endif /* !defined NOID */\r
26 #endif /* !defined lint */\r
27 \r
28 /*\r
29 ** Information about time zone files.\r
30 */\r
31 \r
32 #ifndef TZDIR\r
33 #define TZDIR   "/usr/local/etc/zoneinfo" /* Time zone object file directory */\r
34 #endif /* !defined TZDIR */\r
35 \r
36 #ifndef TZDEFAULT\r
37 #define TZDEFAULT       "localtime"\r
38 #endif /* !defined TZDEFAULT */\r
39 \r
40 #ifndef TZDEFRULES\r
41 #define TZDEFRULES      "posixrules"\r
42 #endif /* !defined TZDEFRULES */\r
43 \r
44 /*\r
45 ** Each file begins with. . .\r
46 */\r
47 \r
48 #define TZ_MAGIC        "TZif"\r
49 \r
50 struct tzhead {\r
51         char    tzh_magic[4];           /* TZ_MAGIC */\r
52         char    tzh_reserved[16];       /* reserved for future use */\r
53         char    tzh_ttisgmtcnt[4];      /* coded number of trans. time flags */\r
54         char    tzh_ttisstdcnt[4];      /* coded number of trans. time flags */\r
55         char    tzh_leapcnt[4];         /* coded number of leap seconds */\r
56         char    tzh_timecnt[4];         /* coded number of transition times */\r
57         char    tzh_typecnt[4];         /* coded number of local time types */\r
58         char    tzh_charcnt[4];         /* coded number of abbr. chars */\r
59 };\r
60 \r
61 /*\r
62 ** . . .followed by. . .\r
63 **\r
64 **      tzh_timecnt (char [4])s         coded transition times a la time(2)\r
65 **      tzh_timecnt (unsigned char)s    types of local time starting at above\r
66 **      tzh_typecnt repetitions of\r
67 **              one (char [4])          coded UTC offset in seconds\r
68 **              one (unsigned char)     used to set tm_isdst\r
69 **              one (unsigned char)     that's an abbreviation list index\r
70 **      tzh_charcnt (char)s             '\0'-terminated zone abbreviations\r
71 **      tzh_leapcnt repetitions of\r
72 **              one (char [4])          coded leap second transition times\r
73 **              one (char [4])          total correction after above\r
74 **      tzh_ttisstdcnt (char)s          indexed by type; if TRUE, transition\r
75 **                                      time is standard time, if FALSE,\r
76 **                                      transition time is wall clock time\r
77 **                                      if absent, transition times are\r
78 **                                      assumed to be wall clock time\r
79 **      tzh_ttisgmtcnt (char)s          indexed by type; if TRUE, transition\r
80 **                                      time is UTC, if FALSE,\r
81 **                                      transition time is local time\r
82 **                                      if absent, transition times are\r
83 **                                      assumed to be local time\r
84 */\r
85 \r
86 /*\r
87 ** In the current implementation, "tzset()" refuses to deal with files that\r
88 ** exceed any of the limits below.\r
89 */\r
90 \r
91 #ifndef TZ_MAX_TIMES\r
92 /*\r
93 ** The TZ_MAX_TIMES value below is enough to handle a bit more than a\r
94 ** year's worth of solar time (corrected daily to the nearest second) or\r
95 ** 138 years of Pacific Presidential Election time\r
96 ** (where there are three time zone transitions every fourth year).\r
97 */\r
98 #define TZ_MAX_TIMES    370\r
99 #endif /* !defined TZ_MAX_TIMES */\r
100 \r
101 #ifndef TZ_MAX_TYPES\r
102 #ifndef NOSOLAR\r
103 #define TZ_MAX_TYPES    256 /* Limited by what (unsigned char)'s can hold */\r
104 #endif /* !defined NOSOLAR */\r
105 #ifdef NOSOLAR\r
106 /*\r
107 ** Must be at least 14 for Europe/Riga as of Jan 12 1995,\r
108 ** as noted by Earl Chew <earl@hpato.aus.hp.com>.\r
109 */\r
110 #define TZ_MAX_TYPES    20      /* Maximum number of local time types */\r
111 #endif /* !defined NOSOLAR */\r
112 #endif /* !defined TZ_MAX_TYPES */\r
113 \r
114 #ifndef TZ_MAX_CHARS\r
115 #define TZ_MAX_CHARS    50      /* Maximum number of abbreviation characters */\r
116                                 /* (limited by what unsigned chars can hold) */\r
117 #endif /* !defined TZ_MAX_CHARS */\r
118 \r
119 #ifndef TZ_MAX_LEAPS\r
120 #define TZ_MAX_LEAPS    50      /* Maximum number of leap second corrections */\r
121 #endif /* !defined TZ_MAX_LEAPS */\r
122 \r
123 #define SECSPERMIN      60\r
124 #define MINSPERHOUR     60\r
125 #define HOURSPERDAY     24\r
126 #define DAYSPERWEEK     7\r
127 #define DAYSPERNYEAR    365\r
128 #define DAYSPERLYEAR    366\r
129 #define SECSPERHOUR     (SECSPERMIN * MINSPERHOUR)\r
130 #define SECSPERDAY      ((long) SECSPERHOUR * HOURSPERDAY)\r
131 #define MONSPERYEAR     12\r
132 \r
133 #define TM_SUNDAY       0\r
134 #define TM_MONDAY       1\r
135 #define TM_TUESDAY      2\r
136 #define TM_WEDNESDAY    3\r
137 #define TM_THURSDAY     4\r
138 #define TM_FRIDAY       5\r
139 #define TM_SATURDAY     6\r
140 \r
141 #define TM_JANUARY      0\r
142 #define TM_FEBRUARY     1\r
143 #define TM_MARCH        2\r
144 #define TM_APRIL        3\r
145 #define TM_MAY          4\r
146 #define TM_JUNE         5\r
147 #define TM_JULY         6\r
148 #define TM_AUGUST       7\r
149 #define TM_SEPTEMBER    8\r
150 #define TM_OCTOBER      9\r
151 #define TM_NOVEMBER     10\r
152 #define TM_DECEMBER     11\r
153 \r
154 #define TM_YEAR_BASE    1900\r
155 \r
156 #define EPOCH_YEAR      1970\r
157 #define EPOCH_WDAY      TM_THURSDAY\r
158 \r
159 /*\r
160 ** Accurate only for the past couple of centuries;\r
161 ** that will probably do.\r
162 */\r
163 \r
164 #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))\r
165 \r
166 #ifndef USG\r
167 \r
168 /*\r
169 ** Use of the underscored variants may cause problems if you move your code to\r
170 ** certain System-V-based systems; for maximum portability, use the\r
171 ** underscore-free variants.  The underscored variants are provided for\r
172 ** backward compatibility only; they may disappear from future versions of\r
173 ** this file.\r
174 */\r
175 \r
176 #define SECS_PER_MIN    SECSPERMIN\r
177 #define MINS_PER_HOUR   MINSPERHOUR\r
178 #define HOURS_PER_DAY   HOURSPERDAY\r
179 #define DAYS_PER_WEEK   DAYSPERWEEK\r
180 #define DAYS_PER_NYEAR  DAYSPERNYEAR\r
181 #define DAYS_PER_LYEAR  DAYSPERLYEAR\r
182 #define SECS_PER_HOUR   SECSPERHOUR\r
183 #define SECS_PER_DAY    SECSPERDAY\r
184 #define MONS_PER_YEAR   MONSPERYEAR\r
185 \r
186 #endif /* !defined USG */\r
187 \r
188 #endif /* !defined TZFILE_H */\r