~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/tztime.cc

  • Committer: Mark Atwood
  • Date: 2011-05-09 00:03:05 UTC
  • mfrom: (2281.4.17 prune2)
  • Revision ID: me@mark.atwood.name-20110509000305-dilr9ms7n7p1dmnk
merge lp:~olafvdspek/drizzle/prune remove tztime

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; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
 
21
 
#include <config.h>
22
 
#include <cstdio>
23
 
#include <drizzled/tztime.h>
24
 
#include <drizzled/gettext.h>
25
 
#include <drizzled/session.h>
26
 
#include <drizzled/time_functions.h>
27
 
#include <drizzled/charset.h>
28
 
 
29
 
namespace drizzled {
30
 
 
31
 
/**
32
 
 * String with names of SYSTEM time zone.
33
 
 */
34
 
static const String tz_SYSTEM_name("SYSTEM", 6, &my_charset_utf8_general_ci);
35
 
 
36
 
 
37
 
/**
38
 
 * Instance of this class represents local time zone used on this system
39
 
 * (specified by TZ environment variable or via any other system mechanism).
40
 
 * It uses system functions (localtime_r, my_system_gmt_sec) for conversion
41
 
 * and is always available. Because of this it is used by default - if there
42
 
 * were no explicit time zone specified. On the other hand because of this
43
 
 * conversion methods provided by this class is significantly slower and
44
 
 * possibly less multi-threaded-friendly than corresponding Time_zone_db
45
 
 * methods so the latter should be preffered there it is possible.
46
 
 */
47
 
class Time_zone_system : public Time_zone
48
 
{
49
 
public:
50
 
  virtual void gmt_sec_to_TIME(type::Time &tmp, type::Time::epoch_t t) const;
51
 
};
52
 
 
53
 
 
54
 
/**
55
 
 * @brief
56
 
 * Converts time from UTC seconds since Epoch (type::Time::epoch_t) representation
57
 
 * to system local time zone broken-down representation.
58
 
 *
59
 
 * @param    tmp   pointer to type::Time structure to fill-in
60
 
 * @param    t     type::Time::epoch_t value to be converted
61
 
 *
62
 
 * Note: We assume that value passed to this function will fit into type::Time::epoch_t range
63
 
 * supported by localtime_r. This conversion is putting restriction on
64
 
 * TIMESTAMP range in MySQL. If we can get rid of SYSTEM time zone at least
65
 
 * for interaction with client then we can extend TIMESTAMP range down to
66
 
 * the 1902 easily.
67
 
 */
68
 
void
69
 
Time_zone_system::gmt_sec_to_TIME(type::Time &tmp, type::Time::epoch_t t) const
70
 
{
71
 
  tmp.store(t);
72
 
}
73
 
 
74
 
 
75
 
static Time_zone_system tz_SYSTEM;
76
 
 
77
 
Time_zone *my_tz_SYSTEM= &tz_SYSTEM;
78
 
 
79
 
} /* namespace drizzled */