From ab433d28e08bbe23bbc75d333ed63343356e043a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 21:32:55 -0400 Subject: 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. --- src/times.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/times.h') diff --git a/src/times.h b/src/times.h index c77cde1d..035d86cd 100644 --- a/src/times.h +++ b/src/times.h @@ -66,12 +66,17 @@ inline bool is_valid(const date_t& moment) { return ! moment.is_not_a_date(); } +extern optional epoch; + #ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK -#define CURRENT_TIME() boost::posix_time::microsec_clock::universal_time() +#define CURRENT_TIME() \ + (epoch ? *epoch : boost::posix_time::microsec_clock::universal_time()) #else -#define CURRENT_TIME() boost::posix_time::second_clock::universal_time() +#define CURRENT_TIME() \ + (epoch ? *epoch : boost::posix_time::second_clock::universal_time()) #endif -#define CURRENT_DATE() boost::gregorian::day_clock::universal_day() +#define CURRENT_DATE() \ + (epoch ? epoch->date() : boost::gregorian::day_clock::universal_day()) extern date_time::weekdays start_of_week; -- cgit v1.2.3