summaryrefslogtreecommitdiff
path: root/src/timezone/tzfile.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/timezone/tzfile.h')
-rw-r--r--src/timezone/tzfile.h40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/timezone/tzfile.h b/src/timezone/tzfile.h
index 0f447a543dc..a358cad5210 100644
--- a/src/timezone/tzfile.h
+++ b/src/timezone/tzfile.h
@@ -3,10 +3,10 @@
/*
* This file is in the public domain, so clarified as of
- * 1996-06-05 by Arthur David Olson ([email protected]).
+ * 1996-06-05 by Arthur David Olson.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/timezone/tzfile.h,v 1.6 2005/10/15 02:49:51 momjian Exp $
+ * $PostgreSQL: pgsql/src/timezone/tzfile.h,v 1.7 2008/02/16 21:16:04 tgl Exp $
*/
/*
@@ -33,7 +33,8 @@
struct tzhead
{
char tzh_magic[4]; /* TZ_MAGIC */
- char tzh_reserved[16]; /* reserved for future use */
+ char tzh_version[1]; /* '\0' or '2' as of 2005 */
+ char tzh_reserved[15]; /* reserved--must be zero */
char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
char tzh_leapcnt[4]; /* coded number of leap seconds */
@@ -69,17 +70,21 @@ struct tzhead
*/
/*
- * In the current implementation, "tzset()" refuses to deal with files that
- * exceed any of the limits below.
+ * If tzh_version is '2' or greater, the above is followed by a second instance
+ * of tzhead and a second instance of the data in which each coded transition
+ * time uses 8 rather than 4 chars,
+ * then a POSIX-TZ-environment-variable-style string for use in handling
+ * instants after the last transition time stored in the file
+ * (with nothing between the newlines if there is no POSIX representation for
+ * such instants).
*/
/*
- * The TZ_MAX_TIMES value below is enough to handle a bit more than a
- * year's worth of solar time (corrected daily to the nearest second) or
- * 138 years of Pacific Presidential Election time
- * (where there are three time zone transitions every fourth year).
+ * In the current implementation, "tzset()" refuses to deal with files that
+ * exceed any of the limits below.
*/
-#define TZ_MAX_TIMES 370
+
+#define TZ_MAX_TIMES 1200
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
@@ -124,11 +129,20 @@ struct tzhead
#define EPOCH_YEAR 1970
#define EPOCH_WDAY TM_THURSDAY
+#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
+
/*
- * Accurate only for the past couple of centuries;
- * that will probably do.
+ * Since everything in isleap is modulo 400 (or a factor of 400), we know that
+ * isleap(y) == isleap(y % 400)
+ * and so
+ * isleap(a + b) == isleap((a + b) % 400)
+ * or
+ * isleap(a + b) == isleap(a % 400 + b % 400)
+ * This is true even if % means modulo rather than Fortran remainder
+ * (which is allowed by C89 but not C99).
+ * We use this to avoid addition overflow problems.
*/
-#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
+#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
#endif /* !defined TZFILE_H */