~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2011-01-19 18:03:32 UTC
  • mfrom: (2088.8.12 timestamp)
  • mto: This revision was merged to the branch mainline in revision 2098.
  • Revision ID: brian@tangent.org-20110119180332-acfk5i8oofp63s40
Merge in time code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
{
32
32
  assert(fixed == 1);
33
33
  str_value.set(buff, buff_length, &my_charset_bin);
 
34
 
34
35
  return &str_value;
35
36
}
36
37
 
40
41
  decimals= DATETIME_DEC;
41
42
  collation.set(&my_charset_bin);
42
43
  
43
 
  memset(&ltime, 0, sizeof(type::Time));
 
44
  ltime.reset();
44
45
 
45
 
  ltime.time_type= DRIZZLE_TIMESTAMP_DATETIME;
 
46
  ltime.time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
46
47
 
47
48
  store_now_in_TIME(&ltime);
 
49
 
48
50
  value= (int64_t) TIME_to_uint64_t_datetime(&ltime);
49
51
 
50
 
  buff_length= (uint) my_datetime_to_str(&ltime, buff);
51
 
  max_length= buff_length;
 
52
  size_t length= type::Time::MAX_STRING_LENGTH;
 
53
  ltime.convert(buff, length);
 
54
 
 
55
  max_length= buff_length= length;
52
56
}
53
57
 
54
58
/**
61
65
  uint32_t fractional_seconds= 0;
62
66
  time_t tmp= session->getCurrentTimestampEpoch(fractional_seconds);
63
67
 
64
 
  (void) cached_temporal.from_time_t(tmp);
65
 
 
66
 
  now_time->year= cached_temporal.years();
67
 
  now_time->month= cached_temporal.months();
68
 
  now_time->day= cached_temporal.days();
69
 
  now_time->hour= cached_temporal.hours();
70
 
  now_time->minute= cached_temporal.minutes();
71
 
  now_time->second= cached_temporal.seconds();
72
 
  now_time->second_part= fractional_seconds;
 
68
#if 0
 
69
  now_time->store(tmp, fractional_seconds, true);
 
70
#endif
 
71
  now_time->store(tmp, fractional_seconds);
73
72
}
74
73
 
75
74
 
83
82
  uint32_t fractional_seconds= 0;
84
83
  time_t tmp= session->getCurrentTimestampEpoch(fractional_seconds);
85
84
 
86
 
  (void) cached_temporal.from_time_t(tmp);
87
 
 
88
 
  now_time->year= cached_temporal.years();
89
 
  now_time->month= cached_temporal.months();
90
 
  now_time->day= cached_temporal.days();
91
 
  now_time->hour= cached_temporal.hours();
92
 
  now_time->minute= cached_temporal.minutes();
93
 
  now_time->second= cached_temporal.seconds();
94
 
  now_time->second_part= fractional_seconds;
 
85
  now_time->store(tmp, fractional_seconds);
95
86
}
96
87
 
97
88
bool Item_func_now::get_temporal(DateTime &to)
100
91
  return true;
101
92
}
102
93
 
103
 
bool Item_func_now::get_date(type::Time *res,
104
 
                             uint32_t )
 
94
bool Item_func_now::get_date(type::Time *res, uint32_t )
105
95
{
106
96
  *res= ltime;
107
97
  return 0;
111
101
int Item_func_now::save_in_field(Field *to, bool )
112
102
{
113
103
  to->set_notnull();
114
 
  return to->store_time(&ltime, DRIZZLE_TIMESTAMP_DATETIME);
 
104
  return to->store_time(&ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
115
105
}
116
106
 
117
107
} /* namespace drizzled */