From 5ad722fcdf2bb2026baa182aaa527858e3f4eb6b Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 25 Sep 2004 07:01:22 -0400 Subject: [PATCH] fixed a problem with interval strings that use only a beg or end date --- walk.cc | 70 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/walk.cc b/walk.cc index 02f7050d..739ad2ef 100644 --- a/walk.cc +++ b/walk.cc @@ -279,43 +279,47 @@ void interval_transactions::operator()(transaction_t& xact) std::difftime(xact.entry->date, interval.end) >= 0)) return; - std::time_t quant = interval.increment(interval.begin); - if (std::difftime(xact.entry->date, quant) > 0) { - if (last_xact) { - start = interval.begin; - finish = quant; - flush(); + if (interval) { + std::time_t quant = interval.increment(interval.begin); + if (std::difftime(xact.entry->date, quant) > 0) { + if (last_xact) { + start = interval.begin; + finish = quant; + flush(); + } + + if (! interval.seconds) { + struct std::tm * desc = std::localtime(&xact.entry->date); + if (interval.years) + desc->tm_mon = 0; + desc->tm_mday = 1; + desc->tm_hour = 0; + desc->tm_min = 0; + desc->tm_sec = 0; + quant = std::mktime(desc); + } + + std::time_t temp; +#if DEBUG_LEVEL >= RELEASE + int cutoff = 10000; +#endif + while (std::difftime(xact.entry->date, + temp = interval.increment(quant)) > 0) { + if (quant == temp) + break; + quant = temp; +#if DEBUG_LEVEL >= RELEASE + assert(--cutoff > 0); +#endif + } + interval.begin = quant; } - if (! interval.seconds) { - struct std::tm * desc = std::localtime(&xact.entry->date); - if (interval.years) - desc->tm_mon = 0; - desc->tm_mday = 1; - desc->tm_hour = 0; - desc->tm_min = 0; - desc->tm_sec = 0; - quant = std::mktime(desc); - } - - std::time_t temp; -#if DEBUG_LEVEL >= RELEASE - int cutoff = 10000; -#endif - while (std::difftime(xact.entry->date, - temp = interval.increment(quant)) > 0) { - if (quant == temp) - break; - quant = temp; -#if DEBUG_LEVEL >= RELEASE - assert(--cutoff > 0); -#endif - } - interval.begin = quant; + subtotal_transactions::operator()(xact); + } else { + (*handler)(xact); } - subtotal_transactions::operator()(xact); - last_xact = &xact; }