Allow date and datetime values to inter-convert

This commit is contained in:
John Wiegley 2009-02-22 22:13:22 -04:00
parent f6b14cc34a
commit ea418c7fbc

View file

@ -907,6 +907,9 @@ void value_t::in_place_cast(type_t cast_type)
case DATE:
switch (cast_type) {
case DATETIME:
set_datetime(datetime_t(as_date(), time_duration(0, 0, 0, 0)));
return;
case STRING:
set_string(format_date(as_date(), string("%Y-%m-%d")));
return;
@ -916,6 +919,9 @@ void value_t::in_place_cast(type_t cast_type)
break;
case DATETIME:
switch (cast_type) {
case DATE:
set_date(as_datetime().date());
return;
case STRING:
set_string(format_datetime(as_datetime(), string("%Y-%m-%d %H:%M:%S")));
return;