~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2011-03-08 23:35:47 UTC
  • mfrom: (2224.2.9 statement2)
  • mto: This revision was merged to the branch mainline in revision 2227.
  • Revision ID: mordred@inaugust.com-20110308233547-w2s3tm5svzv339dp
Merged Olaf - Statement refactor.

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>
27
27
{
28
28
 
29
29
/**
30
 
    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
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(DRIZZLE_TIME *now_time)
 
33
void Item_func_sysdate_local::store_now_in_TIME(type::Time &now_time)
34
34
{
35
 
  Session *session= current_session;
36
 
  session->variables.time_zone->gmt_sec_to_TIME(now_time, time(NULL));
 
35
  getSession().variables.time_zone->gmt_sec_to_TIME(now_time, time(NULL));
37
36
}
38
37
 
39
38
 
40
39
String *Item_func_sysdate_local::val_str(String *)
41
40
{
42
41
  assert(fixed == 1);
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);
 
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
 
46
49
  return &str_value;
47
50
}
48
51
 
50
53
int64_t Item_func_sysdate_local::val_int()
51
54
{
52
55
  assert(fixed == 1);
53
 
  store_now_in_TIME(&ltime);
54
 
  return (int64_t) TIME_to_uint64_t_datetime(&ltime);
 
56
  store_now_in_TIME(ltime);
 
57
  int64_t tmp;
 
58
  ltime.convert(tmp);
 
59
 
 
60
  return tmp;
55
61
}
56
62
 
57
63
double Item_func_sysdate_local::val_real()
58
64
{
59
65
  assert(fixed == 1);
60
 
  store_now_in_TIME(&ltime);
61
 
  return uint64_t2double(TIME_to_uint64_t_datetime(&ltime));
 
66
 
 
67
  store_now_in_TIME(ltime);
 
68
  int64_t tmp;
 
69
  ltime.convert(tmp);
 
70
 
 
71
  return int64_t2double(tmp);
62
72
}
63
73
 
64
74
 
70
80
}
71
81
 
72
82
 
73
 
bool Item_func_sysdate_local::get_date(DRIZZLE_TIME *res,
74
 
                                       uint32_t )
 
83
bool Item_func_sysdate_local::get_date(type::Time &res, uint32_t )
75
84
{
76
 
  store_now_in_TIME(&ltime);
77
 
  *res= ltime;
 
85
  store_now_in_TIME(ltime);
 
86
  res= ltime;
78
87
  return 0;
79
88
}
80
89
 
81
90
 
82
91
int Item_func_sysdate_local::save_in_field(Field *to, bool )
83
92
{
84
 
  store_now_in_TIME(&ltime);
 
93
  store_now_in_TIME(ltime);
85
94
  to->set_notnull();
86
 
  to->store_time(&ltime, DRIZZLE_TIMESTAMP_DATETIME);
 
95
  to->store_time(ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
 
96
 
87
97
  return 0;
88
98
}
89
99