17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/server_includes.h>
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 )
22
#include "drizzled/function/time/from_days.h"
23
#include "drizzled/error.h"
24
#include "drizzled/temporal.h"
30
* Interpret the first argument as a Julian Day Number and fill
31
* our supplied temporal object.
33
bool Item_func_from_days::get_temporal(drizzled::Date &to)
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;
38
* We MUST call val_int() before checking null_value because, stupidly,
39
* a subselect does not evaluate it's scalar items as null until val_xxx()
42
int64_t int_value= args[0]->val_int();
44
/* We return NULL from FROM_DAYS() only when supplied a NULL argument */
45
if (args[0]->null_value)
51
/* OK, now try to convert from our integer */
52
if (! to.from_julian_day_number(int_value))
54
/* Bad input, throw an error */
57
ss << int_value; ss >> tmp;
59
my_error(ER_ARGUMENT_OUT_OF_RANGE, MYF(ME_FATALERROR), tmp.c_str(), func_name());