From c87882076be910beff88c91665614cb7372d8833 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 20 Feb 2009 18:33:02 -0400 Subject: [PATCH] Allow date and datetime values to be formatted into strings --- src/value.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/value.cc b/src/value.cc index f17f2b61..d04e5ef9 100644 --- a/src/value.cc +++ b/src/value.cc @@ -863,6 +863,25 @@ void value_t::in_place_cast(type_t cast_type) } break; + case DATE: + switch (cast_type) { + case STRING: + set_string(format_date(as_date(), string("%Y-%m-%d"))); + return; + default: + break; + } + break; + case DATETIME: + switch (cast_type) { + case STRING: + set_string(format_datetime(as_datetime(), string("%Y-%m-%d %H:%M:%S"))); + return; + default: + break; + } + break; + case INTEGER: switch (cast_type) { case AMOUNT: