summaryrefslogtreecommitdiff
path: root/src/report.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-13 03:40:16 -0500
committerJohn Wiegley <johnw@newartisans.com>2012-03-13 03:40:16 -0500
commitcb317f9d395f44b2c2fc48f02869c3ed0f5ebcd0 (patch)
tree1bdebb84b54c9299ebe85601754c1d5b9131f92c /src/report.cc
parentf35f68823a2054e99ef720ca78cbaf33f4188391 (diff)
downloadfork-ledger-cb317f9d395f44b2c2fc48f02869c3ed0f5ebcd0.tar.gz
fork-ledger-cb317f9d395f44b2c2fc48f02869c3ed0f5ebcd0.tar.bz2
fork-ledger-cb317f9d395f44b2c2fc48f02869c3ed0f5ebcd0.zip
Added format_datetime valexpr function
Diffstat (limited to 'src/report.cc')
-rw-r--r--src/report.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/report.cc b/src/report.cc
index c4f916d7..cf227fe6 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -756,6 +756,15 @@ value_t report_t::fn_format_date(call_scope_t& args)
return string_value(format_date(args.get<date_t>(0), FMT_PRINTED));
}
+value_t report_t::fn_format_datetime(call_scope_t& args)
+{
+ if (args.has<string>(1))
+ return string_value(format_datetime(args.get<datetime_t>(0), FMT_CUSTOM,
+ args.get<string>(1).c_str()));
+ else
+ return string_value(format_datetime(args.get<datetime_t>(0), FMT_PRINTED));
+}
+
value_t report_t::fn_ansify_if(call_scope_t& args)
{
if (args.has<string>(1)) {
@@ -1331,6 +1340,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
case 'f':
if (is_eq(p, "format_date"))
return MAKE_FUNCTOR(report_t::fn_format_date);
+ else if (is_eq(p, "format_datetime"))
+ return MAKE_FUNCTOR(report_t::fn_format_datetime);
else if (is_eq(p, "format"))
return MAKE_FUNCTOR(report_t::fn_format);
else if (is_eq(p, "floor"))