~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/time/sysdate_local.cc

edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
22
#include <drizzled/function/time/sysdate_local.h>
23
23
#include <drizzled/tztime.h>
30
30
    Converts current time in time_t to type::Time represenatation for local
31
31
    time zone. Defines time zone (local) used for whole SYSDATE function.
32
32
*/
33
 
void Item_func_sysdate_local::store_now_in_TIME(type::Time &now_time)
 
33
void Item_func_sysdate_local::store_now_in_TIME(type::Time *now_time)
34
34
{
35
 
  getSession().variables.time_zone->gmt_sec_to_TIME(now_time, time(NULL));
 
35
  Session *session= current_session;
 
36
  session->variables.time_zone->gmt_sec_to_TIME(now_time, time(NULL));
36
37
}
37
38
 
38
39
 
39
40
String *Item_func_sysdate_local::val_str(String *)
40
41
{
41
42
  assert(fixed == 1);
42
 
  store_now_in_TIME(ltime);
43
 
 
44
 
  size_t length= type::Time::MAX_STRING_LENGTH;
45
 
  ltime.convert(buff, length);
46
 
  buff_length= length;
47
 
  str_value.set(buff, length, &my_charset_bin);
48
 
 
 
43
  store_now_in_TIME(&ltime);
 
44
  buff_length= (uint) my_datetime_to_str(&ltime, buff);
 
45
  str_value.set(buff, buff_length, &my_charset_bin);
49
46
  return &str_value;
50
47
}
51
48
 
53
50
int64_t Item_func_sysdate_local::val_int()
54
51
{
55
52
  assert(fixed == 1);
56
 
  store_now_in_TIME(ltime);
57
 
  int64_t tmp;
58
 
  ltime.convert(tmp);
59
 
 
60
 
  return tmp;
 
53
  store_now_in_TIME(&ltime);
 
54
  return (int64_t) TIME_to_uint64_t_datetime(&ltime);
61
55
}
62
56
 
63
57
double Item_func_sysdate_local::val_real()
64
58
{
65
59
  assert(fixed == 1);
66
 
 
67
 
  store_now_in_TIME(ltime);
68
 
  int64_t tmp;
69
 
  ltime.convert(tmp);
70
 
 
71
 
  return int64_t2double(tmp);
 
60
  store_now_in_TIME(&ltime);
 
61
  return uint64_t2double(TIME_to_uint64_t_datetime(&ltime));
72
62
}
73
63
 
74
64
 
80
70
}
81
71
 
82
72
 
83
 
bool Item_func_sysdate_local::get_date(type::Time &res, uint32_t )
 
73
bool Item_func_sysdate_local::get_date(type::Time *res,
 
74
                                       uint32_t )
84
75
{
85
 
  store_now_in_TIME(ltime);
86
 
  res= ltime;
 
76
  store_now_in_TIME(&ltime);
 
77
  *res= ltime;
87
78
  return 0;
88
79
}
89
80
 
90
81
 
91
82
int Item_func_sysdate_local::save_in_field(Field *to, bool )
92
83
{
93
 
  store_now_in_TIME(ltime);
 
84
  store_now_in_TIME(&ltime);
94
85
  to->set_notnull();
95
 
  to->store_time(ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
96
 
 
 
86
  to->store_time(&ltime, DRIZZLE_TIMESTAMP_DATETIME);
97
87
  return 0;
98
88
}
99
89