00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <drizzled/function/cast/time.h>
00024 #include <drizzled/time_functions.h>
00025
00026 namespace drizzled {
00027 namespace function {
00028 namespace cast {
00029
00030 bool Time::get_time(type::Time <ime)
00031 {
00032 bool res= get_arg0_time(ltime);
00033
00034 ltime.truncate(type::DRIZZLE_TIMESTAMP_TIME);
00035
00036 return res;
00037 }
00038
00039 String *Time::val_str(String *str)
00040 {
00041 assert(fixed == 1);
00042 type::Time ltime;
00043
00044 if (not get_arg0_time(ltime))
00045 {
00046 null_value= 0;
00047 ltime.convert(*str, type::DRIZZLE_TIMESTAMP_TIME);
00048
00049 return str;
00050 }
00051
00052 null_value= 1;
00053 return 0;
00054 }
00055
00056 int64_t Time::val_int()
00057 {
00058 assert(fixed == 1);
00059 type::Time ltime;
00060
00061 if (get_time(ltime))
00062 return 0;
00063
00064 return (ltime.neg ? -1 : 1) * (int64_t)((ltime.hour)*10000 + ltime.minute*100 + ltime.second);
00065 }
00066
00067 }
00068 }
00069 }