17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include <drizzled/function/time/now.h>
20
#include <drizzled/server_includes.h>
22
#include <drizzled/functions/time/now.h>
23
#include <drizzled/tztime.h>
23
24
#include <drizzled/session.h>
25
#include "drizzled/temporal.h"
30
String *Item_func_now::val_str(String *)
26
String *Item_func_now::val_str(String *str __attribute__((unused)))
32
28
assert(fixed == 1);
33
str_value.set(buff, buff_length, &my_charset_bin);
29
str_value.set(buff,buff_length, &my_charset_bin);
40
36
decimals= DATETIME_DEC;
41
37
collation.set(&my_charset_bin);
43
memset(<ime, 0, sizeof(DRIZZLE_TIME));
45
ltime.time_type= DRIZZLE_TIMESTAMP_DATETIME;
47
39
store_now_in_TIME(<ime);
48
40
value= (int64_t) TIME_to_uint64_t_datetime(<ime);
55
Converts current time in time_t to DRIZZLE_TIME represenatation for local
47
Converts current time in my_time_t to DRIZZLE_TIME represenatation for local
56
48
time zone. Defines time zone (local) used for whole NOW function.
58
50
void Item_func_now_local::store_now_in_TIME(DRIZZLE_TIME *now_time)
60
52
Session *session= current_session;
61
time_t tmp= session->query_start();
63
(void) cached_temporal.from_time_t(tmp);
65
now_time->year= cached_temporal.years();
66
now_time->month= cached_temporal.months();
67
now_time->day= cached_temporal.days();
68
now_time->hour= cached_temporal.hours();
69
now_time->minute= cached_temporal.minutes();
70
now_time->second= cached_temporal.seconds();
53
session->variables.time_zone->gmt_sec_to_TIME(now_time,
54
(my_time_t)session->query_start());
75
Converts current time in time_t to DRIZZLE_TIME represenatation for UTC
59
Converts current time in my_time_t to DRIZZLE_TIME represenatation for UTC
76
60
time zone. Defines time zone (UTC) used for whole UTC_TIMESTAMP function.
78
62
void Item_func_now_utc::store_now_in_TIME(DRIZZLE_TIME *now_time)
80
Session *session= current_session;
81
time_t tmp= session->query_start();
83
(void) cached_temporal.from_time_t(tmp);
85
now_time->year= cached_temporal.years();
86
now_time->month= cached_temporal.months();
87
now_time->day= cached_temporal.days();
88
now_time->hour= cached_temporal.hours();
89
now_time->minute= cached_temporal.minutes();
90
now_time->second= cached_temporal.seconds();
93
bool Item_func_now::get_temporal(DateTime &to)
64
my_tz_UTC->gmt_sec_to_TIME(now_time,
65
(my_time_t)(current_session->query_start()));
67
We are not flagging this query as using time zone, since it uses fixed
99
72
bool Item_func_now::get_date(DRIZZLE_TIME *res,
73
uint32_t fuzzy_date __attribute__((unused)))
107
int Item_func_now::save_in_field(Field *to, bool )
80
int Item_func_now::save_in_field(Field *to, bool no_conversions __attribute__((unused)))
109
82
to->set_notnull();
110
83
return to->store_time(<ime, DRIZZLE_TIMESTAMP_DATETIME);
113
} /* namespace drizzled */