~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-03-05 08:26:07 UTC
  • mfrom: (910.2.11 mordred-noatomics)
  • Revision ID: brian@tangent.org-20090305082607-30deookk6sdycdeb
Merge from Monty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <drizzled/server_includes.h>
21
21
#include CSTDINT_H
22
22
#include <drizzled/function/time/now.h>
23
 
#include <drizzled/tztime.h>
24
23
#include <drizzled/session.h>
25
24
 
 
25
#include "drizzled/temporal.h"
 
26
 
26
27
String *Item_func_now::val_str(String *)
27
28
{
28
29
  assert(fixed == 1);
35
36
{
36
37
  decimals= DATETIME_DEC;
37
38
  collation.set(&my_charset_bin);
 
39
  
 
40
  memset(&ltime, 0, sizeof(DRIZZLE_TIME));
 
41
 
 
42
  ltime.time_type= DRIZZLE_TIMESTAMP_DATETIME;
38
43
 
39
44
  store_now_in_TIME(&ltime);
40
45
  value= (int64_t) TIME_to_uint64_t_datetime(&ltime);
50
55
void Item_func_now_local::store_now_in_TIME(DRIZZLE_TIME *now_time)
51
56
{
52
57
  Session *session= current_session;
53
 
  session->variables.time_zone->gmt_sec_to_TIME(now_time,
54
 
                                                (time_t)session->query_start());
 
58
  time_t tmp= session->query_start();
 
59
 
 
60
  (void) cached_temporal.from_time_t(tmp);
 
61
 
 
62
  now_time->year= cached_temporal.years();
 
63
  now_time->month= cached_temporal.months();
 
64
  now_time->day= cached_temporal.days();
 
65
  now_time->hour= cached_temporal.hours();
 
66
  now_time->minute= cached_temporal.minutes();
 
67
  now_time->second= cached_temporal.seconds();
55
68
}
56
69
 
57
70
 
61
74
*/
62
75
void Item_func_now_utc::store_now_in_TIME(DRIZZLE_TIME *now_time)
63
76
{
64
 
  my_tz_UTC->gmt_sec_to_TIME(now_time,
65
 
                             (time_t)(current_session->query_start()));
66
 
  /*
67
 
    We are not flagging this query as using time zone, since it uses fixed
68
 
    UTC-SYSTEM time-zone.
69
 
  */
 
77
  Session *session= current_session;
 
78
  time_t tmp= session->query_start();
 
79
 
 
80
  (void) cached_temporal.from_time_t(tmp);
 
81
 
 
82
  now_time->year= cached_temporal.years();
 
83
  now_time->month= cached_temporal.months();
 
84
  now_time->day= cached_temporal.days();
 
85
  now_time->hour= cached_temporal.hours();
 
86
  now_time->minute= cached_temporal.minutes();
 
87
  now_time->second= cached_temporal.seconds();
 
88
}
 
89
 
 
90
bool Item_func_now::get_temporal(drizzled::DateTime &to)
 
91
{
 
92
  to= cached_temporal;
 
93
  return true;
70
94
}
71
95
 
72
96
bool Item_func_now::get_date(DRIZZLE_TIME *res,