~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to sql/tzfile.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2004 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
/* 
 
17
   This file is based on public domain code from ftp://elsie.ncih.nist.gov/
 
18
   Initial source code is in the public domain, so clarified as of
 
19
   1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). 
 
20
*/
 
21
 
 
22
/*
 
23
  Information about time zone files.
 
24
*/
 
25
 
 
26
#ifndef TZDIR
 
27
#define TZDIR   "/usr/share/zoneinfo" /* Time zone object file directory */
 
28
#endif /* !defined TZDIR */
 
29
 
 
30
/*
 
31
  Each file begins with. . .
 
32
*/
 
33
 
 
34
#define TZ_MAGIC        "TZif"
 
35
 
 
36
struct tzhead {
 
37
        uchar   tzh_magic[4];           /* TZ_MAGIC */
 
38
        uchar   tzh_reserved[16];       /* reserved for future use */
 
39
        uchar   tzh_ttisgmtcnt[4];      /* coded number of trans. time flags */
 
40
        uchar   tzh_ttisstdcnt[4];      /* coded number of trans. time flags */
 
41
        uchar   tzh_leapcnt[4];         /* coded number of leap seconds */
 
42
        uchar   tzh_timecnt[4];         /* coded number of transition times */
 
43
        uchar   tzh_typecnt[4];         /* coded number of local time types */
 
44
        uchar   tzh_charcnt[4];         /* coded number of abbr. chars */
 
45
};
 
46
 
 
47
/*
 
48
  . . .followed by. . .
 
49
  
 
50
  tzh_timecnt (char [4])s               coded transition times a la time(2)
 
51
  tzh_timecnt (unsigned char)s          types of local time starting at above
 
52
  tzh_typecnt repetitions of
 
53
    one (char [4])                      coded UTC offset in seconds
 
54
    one (unsigned char)                 used to set tm_isdst
 
55
    one (unsigned char)                 that's an abbreviation list index
 
56
  tzh_charcnt (char)s                   '\0'-terminated zone abbreviations
 
57
  tzh_leapcnt repetitions of
 
58
    one (char [4])                      coded leap second transition times
 
59
    one (char [4])                      total correction after above
 
60
  tzh_ttisstdcnt (char)s                indexed by type; if TRUE, transition
 
61
                                        time is standard time, if FALSE,
 
62
                                        transition time is wall clock time
 
63
                                        if absent, transition times are
 
64
                                        assumed to be wall clock time
 
65
  tzh_ttisgmtcnt (char)s                indexed by type; if TRUE, transition
 
66
                                        time is UTC, if FALSE,
 
67
                                        transition time is local time
 
68
                                        if absent, transition times are
 
69
                                        assumed to be local time
 
70
*/
 
71
 
 
72
/*
 
73
  In the current implementation, we refuse to deal with files that
 
74
  exceed any of the limits below.
 
75
*/
 
76
 
 
77
#ifndef TZ_MAX_TIMES
 
78
/*
 
79
  The TZ_MAX_TIMES value below is enough to handle a bit more than a
 
80
  year's worth of solar time (corrected daily to the nearest second) or
 
81
  138 years of Pacific Presidential Election time
 
82
  (where there are three time zone transitions every fourth year).
 
83
*/
 
84
#define TZ_MAX_TIMES    370
 
85
#endif /* !defined TZ_MAX_TIMES */
 
86
 
 
87
#ifndef TZ_MAX_TYPES
 
88
#ifdef SOLAR
 
89
#define TZ_MAX_TYPES    256 /* Limited by what (unsigned char)'s can hold */
 
90
#else
 
91
/*
 
92
  Must be at least 14 for Europe/Riga as of Jan 12 1995,
 
93
  as noted by Earl Chew <earl@hpato.aus.hp.com>.
 
94
*/
 
95
#define TZ_MAX_TYPES    20      /* Maximum number of local time types */
 
96
#endif /* defined SOLAR */
 
97
#endif /* !defined TZ_MAX_TYPES */
 
98
 
 
99
#ifndef TZ_MAX_CHARS
 
100
#define TZ_MAX_CHARS    50      /* Maximum number of abbreviation characters */
 
101
                                /* (limited by what unsigned chars can hold) */
 
102
#endif /* !defined TZ_MAX_CHARS */
 
103
 
 
104
#ifndef TZ_MAX_LEAPS
 
105
#define TZ_MAX_LEAPS    50      /* Maximum number of leap second corrections */
 
106
#endif /* !defined TZ_MAX_LEAPS */
 
107
 
 
108
#ifndef TZ_MAX_REV_RANGES
 
109
#ifdef SOLAR
 
110
/* Solar (Asia/RiyadhXX) zones need significantly bigger TZ_MAX_REV_RANGES */
 
111
#define TZ_MAX_REV_RANGES (TZ_MAX_TIMES*2+TZ_MAX_LEAPS*2+2)
 
112
#else
 
113
#define TZ_MAX_REV_RANGES (TZ_MAX_TIMES+TZ_MAX_LEAPS+2)
 
114
#endif
 
115
#endif
 
116
 
 
117
#define SECS_PER_MIN    60
 
118
#define MINS_PER_HOUR   60
 
119
#define HOURS_PER_DAY   24
 
120
#define DAYS_PER_WEEK   7
 
121
#define DAYS_PER_NYEAR  365
 
122
#define DAYS_PER_LYEAR  366
 
123
#define SECS_PER_HOUR   (SECS_PER_MIN * MINS_PER_HOUR)
 
124
#define SECS_PER_DAY    ((long) SECS_PER_HOUR * HOURS_PER_DAY)
 
125
#define MONS_PER_YEAR   12
 
126
 
 
127
#define TM_YEAR_BASE    1900
 
128
 
 
129
#define EPOCH_YEAR      1970
 
130
 
 
131
/*
 
132
  Accurate only for the past couple of centuries,
 
133
  that will probably do.
 
134
*/
 
135
 
 
136
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))