~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Olaf van der Spek
  • Date: 2011-02-12 17:09:31 UTC
  • mto: (2167.1.2 build) (2172.1.4 build)
  • mto: This revision was merged to the branch mainline in revision 2168.
  • Revision ID: olafvdspek@gmail.com-20110212170931-k1fg0lzsmm5i3ciq
casts

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(type::Time &ltime)
31
31
{
32
32
  bool res= get_arg0_time(ltime);
33
33
 
34
 
  if (ltime->time_type == DRIZZLE_TIMESTAMP_DATETIME)
35
 
    ltime->year= ltime->month= ltime->day= 0;
36
 
 
37
 
  ltime->time_type= DRIZZLE_TIMESTAMP_TIME;
 
34
  ltime.truncate(type::DRIZZLE_TIMESTAMP_TIME);
38
35
 
39
36
  return res;
40
37
}
44
41
  assert(fixed == 1);
45
42
  type::Time ltime;
46
43
 
47
 
  if (not get_arg0_time(&ltime))
 
44
  if (not get_arg0_time(ltime))
48
45
  {
49
46
    null_value= 0;
50
 
    make_time(&ltime, str);
 
47
    ltime.convert(*str, type::DRIZZLE_TIMESTAMP_TIME);
 
48
 
51
49
    return str;
52
50
  }
53
51
 
60
58
  assert(fixed == 1);
61
59
  type::Time ltime;
62
60
 
63
 
  if (get_time(&ltime))
 
61
  if (get_time(ltime))
64
62
    return 0;
65
63
 
66
64
  return (ltime.neg ? -1 : 1) * (int64_t)((ltime.hour)*10000 + ltime.minute*100 + ltime.second);