1
by brian
clean slate |
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 |
#ifdef USE_PRAGMA_INTERFACE
|
|
18 |
#pragma interface /* gcc class interface */ |
|
19 |
#endif
|
|
20 |
||
21 |
#if !defined(TESTTIME) && !defined(TZINFO2SQL)
|
|
22 |
||
23 |
/**
|
|
24 |
This class represents abstract time zone and provides
|
|
25 |
basic interface for MYSQL_TIME <-> my_time_t conversion.
|
|
26 |
Actual time zones which are specified by DB, or via offset
|
|
27 |
or use system functions are its descendants.
|
|
28 |
*/
|
|
29 |
class Time_zone: public Sql_alloc |
|
30 |
{
|
|
31 |
public: |
|
32 |
Time_zone() {} /* Remove gcc warning */ |
|
33 |
/**
|
|
34 |
Converts local time in broken down MYSQL_TIME representation to
|
|
35 |
my_time_t (UTC seconds since Epoch) represenation.
|
|
36 |
Returns 0 in case of error. Sets in_dst_time_gap to true if date provided
|
|
37 |
falls into spring time-gap (or lefts it untouched otherwise).
|
|
38 |
*/
|
|
39 |
virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, |
|
40 |
my_bool *in_dst_time_gap) const = 0; |
|
41 |
/**
|
|
42 |
Converts time in my_time_t representation to local time in
|
|
43 |
broken down MYSQL_TIME representation.
|
|
44 |
*/
|
|
45 |
virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const = 0; |
|
46 |
/**
|
|
47 |
Because of constness of String returned by get_name() time zone name
|
|
48 |
have to be already zeroended to be able to use String::ptr() instead
|
|
49 |
of c_ptr().
|
|
50 |
*/
|
|
51 |
virtual const String * get_name() const = 0; |
|
52 |
||
53 |
/**
|
|
54 |
We need this only for surpressing warnings, objects of this type are
|
|
55 |
allocated on MEM_ROOT and should not require destruction.
|
|
56 |
*/
|
|
57 |
virtual ~Time_zone() {}; |
|
58 |
};
|
|
59 |
||
60 |
extern Time_zone * my_tz_UTC; |
|
61 |
extern Time_zone * my_tz_SYSTEM; |
|
62 |
extern Time_zone * my_tz_OFFSET0; |
|
63 |
extern Time_zone * my_tz_find(THD *thd, const String *name); |
|
64 |
extern my_bool my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap); |
|
65 |
extern void my_tz_free(); |
|
66 |
extern my_time_t sec_since_epoch_TIME(MYSQL_TIME *t); |
|
67 |
||
68 |
/**
|
|
69 |
Number of elements in table list produced by my_tz_get_table_list()
|
|
70 |
(this table list contains tables which are needed for dynamical loading
|
|
71 |
of time zone descriptions). Actually it is imlementation detail that
|
|
72 |
should not be used anywhere outside of tztime.h and tztime.cc.
|
|
73 |
*/
|
|
74 |
||
75 |
static const int MY_TZ_TABLES_COUNT= 4; |
|
76 |
||
77 |
||
78 |
#endif /* !defined(TESTTIME) && !defined(TZINFO2SQL) */ |