diff options
author | John Wiegley <johnw@newartisans.com> | 2009-10-27 21:32:55 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-10-27 21:32:55 -0400 |
commit | ab433d28e08bbe23bbc75d333ed63343356e043a (patch) | |
tree | 273377e30b59a28de199e45fe66519ff8a387bf3 /src/report.h | |
parent | aae134f69275e4f71ec70d893cdfd0b5839fef8e (diff) | |
download | fork-ledger-ab433d28e08bbe23bbc75d333ed63343356e043a.tar.gz fork-ledger-ab433d28e08bbe23bbc75d333ed63343356e043a.tar.bz2 fork-ledger-ab433d28e08bbe23bbc75d333ed63343356e043a.zip |
Support a --now option, for testing purposes
This sets Ledger's notion of the "current time" to the given date. This
makes it possible to have stable output from budgeting and forecasting
reports, for the sake of baseline tests.
Diffstat (limited to 'src/report.h')
-rw-r--r-- | src/report.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/report.h b/src/report.h index e665ac2d..40097c8d 100644 --- a/src/report.h +++ b/src/report.h @@ -250,6 +250,7 @@ public: HANDLER(market).report(out); HANDLER(monthly).report(out); HANDLER(no_total).report(out); + HANDLER(now_).report(out); HANDLER(only_).report(out); HANDLER(output_).report(out); HANDLER(pager_).report(out); @@ -602,6 +603,15 @@ public: OPTION(report_t, no_total); + OPTION_(report_t, now_, DO_(args) { + date_interval_t interval(args[1].to_string()); + if (! interval.start) + throw_(std::invalid_argument, + _("Could not determine beginning of period '%1'") + << args[1].to_string()); + ledger::epoch = datetime_t(*interval.start); + }); + OPTION__ (report_t, only_, CTOR(report_t, only_) {} |