From 00fe8bc815764a67b6d30411bcf9770320cc08ea Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 28 Oct 2005 07:20:34 +0000 Subject: Added a `terminus' global, which if set marks the "current time" as seen by the value expression logic. This has the effect of changing valexprs that test against the current time, such as for calculating the market value of commodities. --- valexpr.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'valexpr.cc') diff --git a/valexpr.cc b/valexpr.cc index e65ecb26..78f481a6 100644 --- a/valexpr.cc +++ b/valexpr.cc @@ -13,6 +13,8 @@ namespace ledger { std::auto_ptr amount_expr; std::auto_ptr total_expr; +std::time_t terminus = now; + void value_expr_t::compute(value_t& result, const details_t& details) const { switch (kind) { @@ -112,7 +114,7 @@ void value_expr_t::compute(value_t& result, const details_t& details) const else if (details.entry) result = long(details.entry->date()); else - result = long(now); + result = long(terminus); break; case CLEARED: if (details.xact) @@ -286,7 +288,7 @@ void value_expr_t::compute(value_t& result, const details_t& details) const assert(left); left->compute(result, details); - std::time_t moment = now; + std::time_t moment = terminus; if (right) { switch (right->kind) { case DATE: @@ -453,7 +455,7 @@ value_expr_t * parse_value_term(std::istream& in) // Basic terms case 'm': node.reset(new value_expr_t(value_expr_t::CONSTANT_T)); - node->constant_t = now; + node->constant_t = terminus; break; case 'a': node.reset(new value_expr_t(value_expr_t::AMOUNT)); break; -- cgit v1.2.3