1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
4
* Copyright (C) 2008 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/server_includes.h>
22
22
#include <drizzled/function/time/now.h>
23
#include <drizzled/current_session.h>
23
#include <drizzled/tztime.h>
24
24
#include <drizzled/session.h>
26
#include <drizzled/temporal.h>
31
String *Item_func_now::val_str(String *)
26
String *Item_func_now::val_str(String *str __attribute__((unused)))
33
28
assert(fixed == 1);
34
str_value.set(buff, buff_length, &my_charset_bin);
29
str_value.set(buff,buff_length, &my_charset_bin);
42
36
decimals= DATETIME_DEC;
43
37
collation.set(&my_charset_bin);
47
ltime.time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
49
store_now_in_TIME(ltime);
53
size_t length= type::Time::MAX_STRING_LENGTH;
54
ltime.convert(buff, length);
56
max_length= buff_length= length;
39
store_now_in_TIME(<ime);
40
value= (int64_t) TIME_to_uint64_t_datetime(<ime);
42
buff_length= (uint) my_datetime_to_str(<ime, buff);
43
max_length= buff_length;
60
Converts current time in time_t to type::Time represenatation for local
47
Converts current time in my_time_t to DRIZZLE_TIME represenatation for local
61
48
time zone. Defines time zone (local) used for whole NOW function.
63
void Item_func_now_local::store_now_in_TIME(type::Time &now_time)
50
void Item_func_now_local::store_now_in_TIME(DRIZZLE_TIME *now_time)
65
52
Session *session= current_session;
66
uint32_t fractional_seconds= 0;
67
time_t tmp= session->getCurrentTimestampEpoch(fractional_seconds);
70
now_time->store(tmp, fractional_seconds, true);
72
now_time.store(tmp, fractional_seconds);
53
session->variables.time_zone->gmt_sec_to_TIME(now_time,
54
(my_time_t)session->query_start());
77
Converts current time in time_t to type::Time represenatation for UTC
59
Converts current time in my_time_t to DRIZZLE_TIME represenatation for UTC
78
60
time zone. Defines time zone (UTC) used for whole UTC_TIMESTAMP function.
80
void Item_func_now_utc::store_now_in_TIME(type::Time &now_time)
82
Session *session= current_session;
83
uint32_t fractional_seconds= 0;
84
time_t tmp= session->getCurrentTimestampEpoch(fractional_seconds);
86
now_time.store(tmp, fractional_seconds);
89
bool Item_func_now::get_temporal(DateTime &to)
95
bool Item_func_now::get_date(type::Time &res, uint32_t )
62
void Item_func_now_utc::store_now_in_TIME(DRIZZLE_TIME *now_time)
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
72
bool Item_func_now::get_date(DRIZZLE_TIME *res,
73
uint32_t fuzzy_date __attribute__((unused)))
102
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)))
104
82
to->set_notnull();
105
return to->store_time(ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
83
return to->store_time(<ime, DRIZZLE_TIMESTAMP_DATETIME);
108
} /* namespace drizzled */