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
4
* Copyright (C) 2008 Sun Microsystems, Inc.
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/sysdate_local.h>
23
#include <drizzled/tztime.h>
24
23
#include <drizzled/session.h>
24
#include <drizzled/field.h>
25
#include <drizzled/system_variables.h>
27
Converts current time in time_t to DRIZZLE_TIME represenatation for local
30
Converts current time in time_t to type::Time represenatation for local
28
31
time zone. Defines time zone (local) used for whole SYSDATE function.
30
void Item_func_sysdate_local::store_now_in_TIME(DRIZZLE_TIME *now_time)
33
void Item_func_sysdate_local::store_now_in_TIME(type::Time &now_time)
32
Session *session= current_session;
33
session->variables.time_zone->gmt_sec_to_TIME(now_time, time(NULL));
35
now_time.store(time(NULL));
37
String *Item_func_sysdate_local::val_str(String *str __attribute__((unused)))
39
String *Item_func_sysdate_local::val_str(String *)
39
41
assert(fixed == 1);
40
store_now_in_TIME(<ime);
41
buff_length= (uint) my_datetime_to_str(<ime, buff);
42
str_value.set(buff, buff_length, &my_charset_bin);
42
store_now_in_TIME(ltime);
44
size_t length= type::Time::MAX_STRING_LENGTH;
45
ltime.convert(buff, length);
47
str_value.set(buff, length, &my_charset_bin);
47
53
int64_t Item_func_sysdate_local::val_int()
49
55
assert(fixed == 1);
50
store_now_in_TIME(<ime);
51
return (int64_t) TIME_to_uint64_t_datetime(<ime);
56
store_now_in_TIME(ltime);
54
63
double Item_func_sysdate_local::val_real()
56
65
assert(fixed == 1);
57
store_now_in_TIME(<ime);
58
return uint64_t2double(TIME_to_uint64_t_datetime(<ime));
67
store_now_in_TIME(ltime);
71
return int64_t2double(tmp);
65
78
collation.set(&my_charset_bin);
66
max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
79
max_length= DateTime::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
70
bool Item_func_sysdate_local::get_date(DRIZZLE_TIME *res,
71
uint32_t fuzzy_date __attribute__((unused)))
83
bool Item_func_sysdate_local::get_date(type::Time &res, uint32_t )
73
store_now_in_TIME(<ime);
85
store_now_in_TIME(ltime);
79
int Item_func_sysdate_local::save_in_field(Field *to, bool no_conversions __attribute__((unused)))
91
int Item_func_sysdate_local::save_in_field(Field *to, bool )
81
store_now_in_TIME(<ime);
93
store_now_in_TIME(ltime);
83
to->store_time(<ime, DRIZZLE_TIMESTAMP_DATETIME);
95
to->store_time(ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
100
} /* namespace drizzled */