00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <drizzled/function/time/curdate.h>
00023 #include <drizzled/temporal.h>
00024 #include <drizzled/session.h>
00025 #include <drizzled/session/times.h>
00026 #include <drizzled/current_session.h>
00027
00028 namespace drizzled
00029 {
00030
00031 void Item_func_curdate::fix_length_and_dec()
00032 {
00033 collation.set(&my_charset_bin);
00034 decimals=0;
00035 max_length=Date::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
00036
00037 store_now_in_TIME(<ime);
00038
00039
00040 ltime.hour= ltime.minute= ltime.second= 0;
00041 ltime.time_type= type::DRIZZLE_TIMESTAMP_DATE;
00042
00047 cached_temporal.set_years(ltime.year);
00048 cached_temporal.set_months(ltime.month);
00049 cached_temporal.set_days(ltime.day);
00050 }
00051
00056 void Item_func_curdate_local::store_now_in_TIME(type::Time *now_time)
00057 {
00058 (void) cached_temporal.from_time_t(current_session->times.getCurrentTimestampEpoch());
00059
00060 now_time->year= cached_temporal.years();
00061 now_time->month= cached_temporal.months();
00062 now_time->day= cached_temporal.days();
00063 now_time->hour= 0;
00064 now_time->minute= 0;
00065 now_time->second= 0;
00066 now_time->second_part= 0;
00067 }
00068
00073 void Item_func_curdate_utc::store_now_in_TIME(type::Time *now_time)
00074 {
00075 (void) cached_temporal.from_time_t(current_session->times.getCurrentTimestampEpoch());
00076
00077 now_time->year= cached_temporal.years();
00078 now_time->month= cached_temporal.months();
00079 now_time->day= cached_temporal.days();
00080 now_time->hour= 0;
00081 now_time->minute= 0;
00082 now_time->second= 0;
00083 now_time->second_part= 0;
00084 }
00085
00086 bool Item_func_curdate::get_temporal(Date &to)
00087 {
00088 to= cached_temporal;
00089 return true;
00090 }
00091
00092 }