CUBRID Engine  latest
timezone_lib_common.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * timezone_lib_common.h : Timezone structures used at runtime and at
21  * shared library generation
22  */
23 #ifndef _TIMEZONE_LIB_COMMON_H_
24 #define _TIMEZONE_LIB_COMMON_H_
25 
26 #define TZ_COUNTRY_CODE_LEN 2
27 #define TZ_COUNTRY_CODE_SIZE 3
28 #define TZ_COUNTRY_NAME_SIZE 50
29 #define TZ_DS_RULESET_NAME_SIZE 16
30 #define TZ_GENERIC_NAME_SIZE 40
31 #define TZ_MAX_FORMAT_SIZE 32
32 #define TZ_WINDOWS_ZONE_NAME_SIZE 70
33 #define TZ_CHECKSUM_SIZE 32
34 
35 /*
36  * The defines below are types of the data representation for the "ON" column
37  * from the daylight saving rules. The "ON" column can be either a number
38  * representing a day of the month, an identifier like "last<Weekday>" of the
39  * specified month, such as "lastSun" or "lastFri", or a rule representing a
40  * particular weekday after a specific day of the month, such as "Fri>=24".
41  */
42 typedef enum
43 {
47 } TZ_DS_TYPE;
48 
49 /*
50  * The values below are needed for identifying and properly computing time
51  * when a daylight saving event occurs, namely to track the suffixes
52  * 's' (standard local time), 'g', 'u' and 'z' (GMT/UTC/Zulu), 'w' or
53  * none (local wall clock time), from the AT column in daylight saving rules.
54  */
55 typedef enum
56 {
60 } TZ_TIME_TYPE;
61 
62 /*
63  * The defines below are used for identifying the type of timezone library and
64  * files which the gen_tz utility should use as input, and what to generate
65  * as output. A C file to be compiled into a shared library is always
66  * generated; the question is what to include in it, and weather or not it is
67  * necessary to also generate either a new or an updated C file containing
68  * timezone names and IDs (which should be included in the new CUBRID release)
69  * TZ_GEN_TYPE_NEW - generate the TZ/ID arrays from scratch;
70  * - include all the data from the TZ database into the
71  * C file to be compiled into the TZ shared library
72  * TZ_GEN_TYPE_UPDATE - don't generate any TZ/ID arrays
73  * - use the existing TZ/ID arrays to identify which
74  * timezones need to be updated;
75  * - no new time zones are added;
76  * TZ_GEN_TYPE_EXTEND - this flag is used when generating a new timezone library
77  * using the old library and the new timezone data
78  */
79 typedef enum
80 {
84 } TZ_GEN_TYPE;
85 
86 /* DATA STRUCTURES */
87 typedef struct tz_country TZ_COUNTRY;
88 struct tz_country
89 {
92 };
93 
95 {
98 };
100 
102 {
105 };
106 typedef enum ds_type DS_TYPE;
107 
110 {
111  int gmt_off; /* time offset from UTC, in seconds */
112  int ds_ruleset; /* it is either an index in DS ruleset or a fixed amount of daylight saving (in
113  * seconds) */
114  unsigned short until_year;
115  unsigned char until_mon; /* 0 - 11 */
116  unsigned char until_day; /* 0 - 30 */
117  unsigned char until_hour;
118  unsigned char until_min;
119  unsigned char until_sec;
120  TZ_TIME_TYPE until_time_type; /* type for until: standard, wall, UTC */
121  TZ_UNTIL_FLAG until_flag; /* 0 if no ending time is specified; 1 otherwise */
122  DS_TYPE ds_type; /* 1 if ds_ruleset is a ruleset id, 0 if it is a fixed time offset (seconds) */
123  int julian_date; /* encoded julian date for until_year, until_mon, and until_day */
124  const char *std_format; /* format for standard time */
125  const char *save_format; /* format for DST time (when saving time) */
126  const char *var_format; /* format for variable time (mutually excluded with std and save formats */
127 };
128 
129 typedef struct tz_timezone TZ_TIMEZONE;
131 {
132  int zone_id;
136 };
137 
140 {
142  unsigned char day_of_month; /* possible values: 0-27/28/29/30, depending on the month; or 31 if "ON" value is
143  * last<day> */
144  unsigned char day_of_week; /* possible values: 0-6, where 0=Sunday, 6=Saturday */
145 };
146 
147 typedef struct tz_ds_rule TZ_DS_RULE;
149 {
150  short from_year;
151  short to_year; /* -1 if column value is "max" e.g. up to now */
152  unsigned char in_month; /* month when the daylight saving event occurs 0 - 11 */
153  TZ_DS_CHANGE_ON change_on; /* day of month, fixed or relative */
154  int at_time; /* time when DS event occurs */
155  TZ_TIME_TYPE at_time_type; /* type for at_time: standard, wall, UTC */
156  int save_time; /* amount of time saved, in seconds */
157  const char *letter_abbrev; /* letter(s) to be used in the time zone string ID */
158 };
159 
162 {
164  int count;
165  const char *ruleset_name;
166  int to_year_max; /* maximum of all to_year numbers in the ruleset */
167  const char *default_abrev; /* default abbreviation for all the ds_rules in this ruleset that have daylight
168  * saving time 0 */
169 };
170 
171 typedef struct tz_name TZ_NAME;
172 struct tz_name
173 {
174  int zone_id;
175  const char *name;
176  unsigned char is_alias; /* 1 if it is an alias, 0 otherwise */
177 };
178 
179 typedef struct tz_leap_sec TZ_LEAP_SEC;
181 {
182  unsigned short year;
183  unsigned char month;
184  unsigned char day;
185  unsigned char corr_negative;
186  unsigned char is_rolling;
187 };
188 
191 {
192  char windows_zone[TZ_WINDOWS_ZONE_NAME_SIZE + 1];
193  char territory[TZ_COUNTRY_CODE_SIZE + 1];
195 };
196 
197 typedef struct tz_data TZ_DATA;
198 struct tz_data
199 {
202 
206 
209 
212 
215 
218 
221 #if defined (WINDOWS)
222  int windows_iana_map_count;
223  TZ_WINDOWS_IANA_MAP *windows_iana_map;
224 #endif
225  /*
226  * 32 digits for the md5 checksum
227  */
228  char checksum[TZ_CHECKSUM_SIZE + 1];
229 };
230 
231 #endif /* _TIMEZONE_LIB_COMMON_H_ */
TZ_DS_RULESET * ds_rulesets
const char * name
enum ds_type DS_TYPE
unsigned char until_hour
unsigned char month
const char * var_format
char code[TZ_COUNTRY_CODE_SIZE]
tz_until_flag
TZ_DS_CHANGE_ON change_on
const char * letter_abbrev
#define TZ_COUNTRY_CODE_SIZE
const char * std_format
unsigned char day
TZ_TIME_TYPE at_time_type
TZ_TIME_TYPE until_time_type
TZ_COUNTRY * countries
#define TZ_CHECKSUM_SIZE
unsigned char until_mon
TZ_TIME_TYPE
const char * save_format
TZ_NAME * names
unsigned char until_min
unsigned short until_year
TZ_UNTIL_FLAG until_flag
TZ_TIMEZONE * timezones
unsigned char is_alias
unsigned char day_of_month
unsigned char until_day
unsigned char is_rolling
const char * ruleset_name
unsigned char day_of_week
const char * default_abrev
char full_name[TZ_COUNTRY_NAME_SIZE]
#define TZ_WINDOWS_ZONE_NAME_SIZE
TZ_DS_RULE * ds_rules
char ** timezone_names
unsigned short year
unsigned char in_month
unsigned char until_sec
TZ_LEAP_SEC * ds_leap_sec
#define TZ_COUNTRY_NAME_SIZE
TZ_OFFSET_RULE * offset_rules
enum tz_until_flag TZ_UNTIL_FLAG
unsigned char corr_negative