~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/tztime.h

  • Committer: Andrew Hutchings
  • Date: 2011-02-01 10:23:22 UTC
  • mto: (2136.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2137.
  • Revision ID: andrew@linuxjedi.co.uk-20110201102322-oxztcyrjzg3c7yta
Fix counters cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#ifndef DRIZZLED_TZTIME_H
 
22
#define DRIZZLED_TZTIME_H
 
23
 
 
24
#include "drizzled/memory/sql_alloc.h"
 
25
 
 
26
#include "drizzled/type/time.h"
 
27
 
 
28
namespace drizzled
 
29
{
 
30
 
 
31
class String;
 
32
 
 
33
namespace type {
 
34
class Time;
 
35
}
 
36
 
 
37
/**
 
38
  This class represents abstract time zone and provides
 
39
  basic interface for type::Time <-> type::Time::epoch_t conversion.
 
40
  Actual time zones which are specified by DB, or via offset
 
41
  or use system functions are its descendants.
 
42
*/
 
43
class Time_zone: public memory::SqlAlloc
 
44
{
 
45
public:
 
46
  Time_zone() {}                              /* Remove gcc warning */
 
47
  /**
 
48
    Converts local time in broken down type::Time representation to
 
49
    type::Time::epoch_t (UTC seconds since Epoch) represenation.
 
50
    Returns 0 in case of error. Sets in_dst_time_gap to true if date provided
 
51
    falls into spring time-gap (or lefts it untouched otherwise).
 
52
  */
 
53
  virtual type::Time::epoch_t TIME_to_gmt_sec(const type::Time &t,
 
54
                                              bool *in_dst_time_gap) const = 0;
 
55
  /**
 
56
    Converts time in type::Time::epoch_t representation to local time in
 
57
    broken down type::Time representation.
 
58
  */
 
59
  virtual void gmt_sec_to_TIME(type::Time &tmp, type::Time::epoch_t t) const = 0;
 
60
 
 
61
  /**
 
62
    Because of constness of String returned by get_name() time zone name
 
63
    have to be already zeroended to be able to use String::ptr() instead
 
64
    of c_ptr().
 
65
  */
 
66
  virtual const String * get_name() const = 0;
 
67
 
 
68
  /**
 
69
    We need this only for surpressing warnings, objects of this type are
 
70
    allocated on memory::Root and should not require destruction.
 
71
  */
 
72
  virtual ~Time_zone() {};
 
73
};
 
74
 
 
75
extern Time_zone * my_tz_SYSTEM;
 
76
extern Time_zone * my_tz_find(Session *session, const String *name);
 
77
extern bool     my_tz_init(Session *org_session, const char *default_tzname);
 
78
 
 
79
} /* namespace drizzled */
 
80
 
 
81
#endif /* DRIZZLED_TZTIME_H */