summaryrefslogtreecommitdiff
path: root/src/report.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-13 02:04:09 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-13 02:04:09 -0400
commitf6b93a3f5a29c5262fb812fb03676124b355f013 (patch)
tree160adeb8acbd2597c3988d23964a1c9ef09e3505 /src/report.cc
parentc0fd8d5e152c910b64c8d3536864d033d4ac9ffc (diff)
downloadfork-ledger-f6b93a3f5a29c5262fb812fb03676124b355f013.tar.gz
fork-ledger-f6b93a3f5a29c5262fb812fb03676124b355f013.tar.bz2
fork-ledger-f6b93a3f5a29c5262fb812fb03676124b355f013.zip
Added a new valexpr function: format_date
This can be used to format dates with a specific pattern, such as: format_date(entry.date, "%Y/%m/%d") This is used by the print command to ensure that Ledger is able to parse back what it prints.
Diffstat (limited to 'src/report.cc')
-rw-r--r--src/report.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/report.cc b/src/report.cc
index 1f8e4743..e1497dac 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -244,6 +244,11 @@ value_t report_t::fn_join(call_scope_t& args)
return string_value(out.str());
}
+value_t report_t::fn_format_date(call_scope_t& args)
+{
+ return string_value(format_date(args[0].to_date(), args[1].to_string()));
+}
+
namespace {
template <class Type = xact_t,
class handler_ptr = xact_handler_ptr,
@@ -567,6 +572,11 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
return MAKE_FUNCTOR(report_t::fn_display_total);
break;
+ case 'f':
+ if (is_eq(p, "format_date"))
+ return MAKE_FUNCTOR(report_t::fn_format_date);
+ break;
+
case 'j':
if (is_eq(p, "join"))
return MAKE_FUNCTOR(report_t::fn_join);