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/date.h>
22
#include "drizzled/function/time/date.h"
23
#include "drizzled/temporal.h"
24
25
String *Item_date::val_str(String *str)
28
if (get_date(<ime, TIME_FUZZY_DATE))
29
/* We have our subclass convert a Date temporal for us */
30
drizzled::Date temporal;
31
if (! get_temporal(temporal))
32
return (String *) NULL; /* get_temporal throws error. */
30
34
if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
37
return (String *) NULL;
35
make_date((DATE_TIME_FORMAT *) 0, <ime, str);
40
/* Convert the Date to a string and return it */
42
temporal.to_string(str->c_ptr(), &new_length);
43
str->length((uint32_t) new_length);
40
47
int64_t Item_date::val_int()
44
if (get_date(<ime, TIME_FUZZY_DATE))
46
return (int64_t) (ltime.year*10000L+ltime.month*100+ltime.day);
51
/* We have our subclass convert a Date temporal for us */
52
drizzled::Date temporal;
53
if (! get_temporal(temporal))
54
return 0; /* get_temporal throws error. */
56
/* Convert the Date to a string and return it */
58
temporal.to_int32_t(&int_value);
59
return (int64_t) int_value;