23
#include <drizzled/tztime.h>
24
#include <drizzled/gettext.h>
25
#include <drizzled/session.h>
26
#include <drizzled/time_functions.h>
23
#include "drizzled/tzfile.h"
24
#include "drizzled/tztime.h"
25
#include "drizzled/gettext.h"
26
#include "drizzled/session.h"
27
#include "drizzled/time_functions.h"
50
51
Time_zone_system() {} /* Remove gcc warning */
51
virtual type::Time::epoch_t TIME_to_gmt_sec(const type::Time &t,
52
bool *in_dst_time_gap) const;
53
virtual void gmt_sec_to_TIME(type::Time &tmp, type::Time::epoch_t t) const;
52
virtual time_t TIME_to_gmt_sec(const type::Time *t,
53
bool *in_dst_time_gap) const;
54
virtual void gmt_sec_to_TIME(type::Time *tmp, time_t t) const;
54
55
virtual const String * get_name() const;
60
61
* Converts local time in system time zone in type::Time representation
61
* to its type::Time::epoch_t representation.
62
* to its time_t representation.
64
65
* This method uses system function (localtime_r()) for conversion
65
* local time in system time zone in type::Time structure to its type::Time::epoch_t
66
* local time in system time zone in type::Time structure to its time_t
66
67
* representation. Unlike the same function for Time_zone_db class
67
68
* it it won't handle unnormalized input properly. Still it will
68
* return lowest possible type::Time::epoch_t in case of ambiguity or if we
69
* return lowest possible time_t in case of ambiguity or if we
69
70
* provide time corresponding to the time-gap.
71
72
* You should call init_time() function before using this function.
77
78
* spring time-gap) and is not touched otherwise.
80
* Corresponding type::Time::epoch_t value or 0 in case of error
81
* Corresponding time_t value or 0 in case of error
83
Time_zone_system::TIME_to_gmt_sec(const type::Time &t, bool *in_dst_time_gap) const
84
Time_zone_system::TIME_to_gmt_sec(const type::Time *t, bool *in_dst_time_gap) const
86
type::Time::epoch_t tmp;
87
t.convert(tmp, ¬_used, in_dst_time_gap);
87
return my_system_gmt_sec(t, ¬_used, in_dst_time_gap);
94
* Converts time from UTC seconds since Epoch (type::Time::epoch_t) representation
93
* Converts time from UTC seconds since Epoch (time_t) representation
95
94
* to system local time zone broken-down representation.
97
96
* @param tmp pointer to type::Time structure to fill-in
98
* @param t type::Time::epoch_t value to be converted
97
* @param t time_t value to be converted
100
* Note: We assume that value passed to this function will fit into type::Time::epoch_t range
99
* Note: We assume that value passed to this function will fit into time_t range
101
100
* supported by localtime_r. This conversion is putting restriction on
102
101
* TIMESTAMP range in MySQL. If we can get rid of SYSTEM time zone at least
103
102
* for interaction with client then we can extend TIMESTAMP range down to
104
103
* the 1902 easily.
107
Time_zone_system::gmt_sec_to_TIME(type::Time &tmp, type::Time::epoch_t t) const
106
Time_zone_system::gmt_sec_to_TIME(type::Time *tmp, time_t t) const
109
time_t tmp_t= (time_t)t;
111
localtime_r(&tmp_t, &tmp_tm);
112
localtime_to_TIME(tmp, &tmp_tm);
113
tmp->time_type= DRIZZLE_TIMESTAMP_DATETIME;
128
132
Time_zone *my_tz_SYSTEM= &tz_SYSTEM;
137
* Initialize time zone support infrastructure.
140
* This function will init memory structures needed for time zone support,
141
* it will register mandatory SYSTEM time zone in them. It will try to open
142
* mysql.time_zone* tables and load information about default time zone and
143
* information which further will be shared among all time zones loaded.
144
* If system tables with time zone descriptions don't exist it won't fail
145
* (unless default_tzname is time zone from tables). If bootstrap parameter
146
* is true then this routine assumes that we are in bootstrap mode and won't
147
* load time zone descriptions unless someone specifies default time zone
148
* which is supposedly stored in those tables.
149
* It'll also set default time zone if it is specified.
151
* @param session current thread object
152
* @param default_tzname default time zone or 0 if none.
153
* @param bootstrap indicates whenever we are in bootstrap mode
160
my_tz_init(Session *session, const char *default_tzname)
164
String tmp_tzname2(default_tzname, &my_charset_utf8_general_ci);
166
Time zone tables may be open here, and my_tz_find() may open
167
most of them once more, but this is OK for system tables open
170
if (!(global_system_variables.time_zone= my_tz_find(session, &tmp_tzname2)))
172
errmsg_printf(ERRMSG_LVL_ERROR,
173
_("Fatal error: Illegal or unknown default time zone '%s'"),
184
* Get Time_zone object for specified time zone.
187
* Not implemented yet. This needs to hook into some sort of OS system call.
190
my_tz_find(Session *,
130
196
} /* namespace drizzled */