~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2010-12-25 00:28:49 UTC
  • mto: This revision was merged to the branch mainline in revision 2031.
  • Revision ID: brian@tangent.org-20101225002849-g73mg6ihulajis0o
First pass in refactoring of the name of my_decimal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
namespace function {
28
28
namespace cast {
29
29
 
30
 
bool Time::get_time(type::Time &ltime)
 
30
bool Time::get_time(DRIZZLE_TIME *ltime)
31
31
{
32
32
  bool res= get_arg0_time(ltime);
33
33
 
34
 
  ltime.truncate(type::DRIZZLE_TIMESTAMP_TIME);
 
34
  if (ltime->time_type == DRIZZLE_TIMESTAMP_DATETIME)
 
35
    ltime->year= ltime->month= ltime->day= 0;
 
36
 
 
37
  ltime->time_type= DRIZZLE_TIMESTAMP_TIME;
35
38
 
36
39
  return res;
37
40
}
39
42
String *Time::val_str(String *str)
40
43
{
41
44
  assert(fixed == 1);
42
 
  type::Time ltime;
 
45
  DRIZZLE_TIME ltime;
43
46
 
44
 
  if (not get_arg0_time(ltime))
 
47
  if (not get_arg0_time(&ltime))
45
48
  {
46
49
    null_value= 0;
47
 
    ltime.convert(*str, type::DRIZZLE_TIMESTAMP_TIME);
48
 
 
 
50
    make_time(&ltime, str);
49
51
    return str;
50
52
  }
51
53
 
56
58
int64_t Time::val_int()
57
59
{
58
60
  assert(fixed == 1);
59
 
  type::Time ltime;
 
61
  DRIZZLE_TIME ltime;
60
62
 
61
 
  if (get_time(ltime))
 
63
  if (get_time(&ltime))
62
64
    return 0;
63
65
 
64
66
  return (ltime.neg ? -1 : 1) * (int64_t)((ltime.hour)*10000 + ltime.minute*100 + ltime.second);