summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-20 18:33:02 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-20 18:33:02 -0400
commitc87882076be910beff88c91665614cb7372d8833 (patch)
treeb8de0a17759c15abb26ff5d5edb556b2f94653ac /src
parentb94512e4cce884ad2df4f86e0947f610468e89c2 (diff)
downloadfork-ledger-c87882076be910beff88c91665614cb7372d8833.tar.gz
fork-ledger-c87882076be910beff88c91665614cb7372d8833.tar.bz2
fork-ledger-c87882076be910beff88c91665614cb7372d8833.zip
Allow date and datetime values to be formatted into strings
Diffstat (limited to 'src')
-rw-r--r--src/value.cc19
1 files changed, 19 insertions, 0 deletions
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: