~drizzle-trunk/drizzle/development

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
/**
22
  This class represents abstract time zone and provides 
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
23
  basic interface for DRIZZLE_TIME <-> my_time_t conversion.
1 by brian
clean slate
24
  Actual time zones which are specified by DB, or via offset 
25
  or use system functions are its descendants.
26
*/
27
class Time_zone: public Sql_alloc 
28
{
29
public:
30
  Time_zone() {}                              /* Remove gcc warning */
31
  /**
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
32
    Converts local time in broken down DRIZZLE_TIME representation to 
1 by brian
clean slate
33
    my_time_t (UTC seconds since Epoch) represenation.
34
    Returns 0 in case of error. Sets in_dst_time_gap to true if date provided
35
    falls into spring time-gap (or lefts it untouched otherwise).
36
  */
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
37
  virtual my_time_t TIME_to_gmt_sec(const DRIZZLE_TIME *t, 
93 by Brian Aker
Convert tztime.cc to bool from my_bool.
38
                                    bool *in_dst_time_gap) const = 0;
1 by brian
clean slate
39
  /**
40
    Converts time in my_time_t representation to local time in
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
41
    broken down DRIZZLE_TIME representation.
1 by brian
clean slate
42
  */
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
43
  virtual void   gmt_sec_to_TIME(DRIZZLE_TIME *tmp, my_time_t t) const = 0;
1 by brian
clean slate
44
  /**
45
    Because of constness of String returned by get_name() time zone name 
46
    have to be already zeroended to be able to use String::ptr() instead
47
    of c_ptr().
48
  */
49
  virtual const String * get_name() const = 0;
50
51
  /** 
52
    We need this only for surpressing warnings, objects of this type are
53
    allocated on MEM_ROOT and should not require destruction.
54
  */
55
  virtual ~Time_zone() {};
56
};
57
58
extern Time_zone * my_tz_UTC;
59
extern Time_zone * my_tz_SYSTEM;
60
extern Time_zone * my_tz_OFFSET0;
61
extern Time_zone * my_tz_find(THD *thd, const String *name);
93 by Brian Aker
Convert tztime.cc to bool from my_bool.
62
extern bool     my_tz_init(THD *org_thd, const char *default_tzname, bool bootstrap);
1 by brian
clean slate
63
extern void        my_tz_free();
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
64
extern my_time_t   sec_since_epoch_TIME(DRIZZLE_TIME *t);