~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/tztime.h

  • Committer: patrick crews
  • Date: 2011-06-08 03:02:27 UTC
  • mto: This revision was merged to the branch mainline in revision 2329.
  • Revision ID: gleebix@gmail.com-20110608030227-updkyv2652zvfajc
Initial voodoo worked to give us a crashme mode.  Need docs still

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
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
 
#if TIME_WITH_SYS_TIME
25
 
# include <sys/time.h>
26
 
# include <time.h>
27
 
#else
28
 
# if HAVE_SYS_TIME_H
29
 
#  include <sys/time.h>
30
 
# else
31
 
#  include <time.h>
32
 
# endif
33
 
#endif
34
 
 
35
 
#include "drizzled/memory/sql_alloc.h"
36
 
 
37
 
namespace drizzled
38
 
{
39
 
 
40
 
class String;
41
 
typedef struct st_drizzle_time DRIZZLE_TIME;
42
 
 
43
 
/**
44
 
  This class represents abstract time zone and provides
45
 
  basic interface for DRIZZLE_TIME <-> time_t conversion.
46
 
  Actual time zones which are specified by DB, or via offset
47
 
  or use system functions are its descendants.
48
 
*/
49
 
class Time_zone: public memory::SqlAlloc
50
 
{
51
 
public:
52
 
  Time_zone() {}                              /* Remove gcc warning */
53
 
  /**
54
 
    Converts local time in broken down DRIZZLE_TIME representation to
55
 
    time_t (UTC seconds since Epoch) represenation.
56
 
    Returns 0 in case of error. Sets in_dst_time_gap to true if date provided
57
 
    falls into spring time-gap (or lefts it untouched otherwise).
58
 
  */
59
 
  virtual time_t TIME_to_gmt_sec(const DRIZZLE_TIME *t,
60
 
                                 bool *in_dst_time_gap) const = 0;
61
 
  /**
62
 
    Converts time in time_t representation to local time in
63
 
    broken down DRIZZLE_TIME representation.
64
 
  */
65
 
  virtual void   gmt_sec_to_TIME(DRIZZLE_TIME *tmp, time_t t) const = 0;
66
 
  /**
67
 
    Because of constness of String returned by get_name() time zone name
68
 
    have to be already zeroended to be able to use String::ptr() instead
69
 
    of c_ptr().
70
 
  */
71
 
  virtual const String * get_name() const = 0;
72
 
 
73
 
  /**
74
 
    We need this only for surpressing warnings, objects of this type are
75
 
    allocated on memory::Root and should not require destruction.
76
 
  */
77
 
  virtual ~Time_zone() {};
78
 
};
79
 
 
80
 
extern Time_zone * my_tz_SYSTEM;
81
 
extern Time_zone * my_tz_find(Session *session, const String *name);
82
 
extern bool     my_tz_init(Session *org_session, const char *default_tzname);
83
 
 
84
 
} /* namespace drizzled */
85
 
 
86
 
#endif /* DRIZZLED_TZTIME_H */