17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include <boost/lexical_cast.hpp>
22
#include "drizzled/function/time/from_days.h"
23
#include "drizzled/error.h"
24
#include "drizzled/temporal.h"
33
* Interpret the first argument as a Julian Day Number and fill
34
* our supplied temporal object.
36
bool Item_func_from_days::get_temporal(Date &to)
41
* We MUST call val_int() before checking null_value because, stupidly,
42
* a subselect does not evaluate it's scalar items as null until val_xxx()
45
int64_t int_value= args[0]->val_int();
47
/* We return NULL from FROM_DAYS() only when supplied a NULL argument */
48
if (args[0]->null_value)
54
/* OK, now try to convert from our integer */
55
if (! to.from_julian_day_number(int_value))
57
/* Bad input, throw an error */
58
std::string tmp(boost::lexical_cast<std::string>(int_value));
60
my_error(ER_ARGUMENT_OUT_OF_RANGE, MYF(ME_FATALERROR), tmp.c_str(), func_name());
20
#include <drizzled/server_includes.h>
22
#include <drizzled/function/time/from_days.h>
24
bool Item_func_from_days::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date __attribute__((unused)))
26
int64_t value=args[0]->val_int();
27
if ((null_value=args[0]->null_value))
29
memset(ltime, 0, sizeof(DRIZZLE_TIME));
30
get_date_from_daynr((long) value, <ime->year, <ime->month, <ime->day);
31
ltime->time_type= DRIZZLE_TIMESTAMP_DATE;
66
} /* namespace drizzled */