summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-09-25 07:01:22 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-09-25 07:01:22 -0400
commit5ad722fcdf2bb2026baa182aaa527858e3f4eb6b (patch)
treea8525fe499b6f2266468b91d2bf3a92bc0779228
parentb1aa1344ae07cab6814d5f06053b0c7bfdc9861a (diff)
downloadfork-ledger-5ad722fcdf2bb2026baa182aaa527858e3f4eb6b.tar.gz
fork-ledger-5ad722fcdf2bb2026baa182aaa527858e3f4eb6b.tar.bz2
fork-ledger-5ad722fcdf2bb2026baa182aaa527858e3f4eb6b.zip
fixed a problem with interval strings that use only a beg or end date
-rw-r--r--walk.cc64
1 files changed, 34 insertions, 30 deletions
diff --git a/walk.cc b/walk.cc
index 02f7050d..739ad2ef 100644
--- a/walk.cc
+++ b/walk.cc
@@ -279,42 +279,46 @@ 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.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 (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;
+ int cutoff = 10000;
#endif
- while (std::difftime(xact.entry->date,
- temp = interval.increment(quant)) > 0) {
- if (quant == temp)
- break;
- quant = temp;
+ while (std::difftime(xact.entry->date,
+ temp = interval.increment(quant)) > 0) {
+ if (quant == temp)
+ break;
+ quant = temp;
#if DEBUG_LEVEL >= RELEASE
- assert(--cutoff > 0);
+ assert(--cutoff > 0);
#endif
+ }
+ interval.begin = quant;
}
- interval.begin = quant;
- }
- subtotal_transactions::operator()(xact);
+ subtotal_transactions::operator()(xact);
+ } else {
+ (*handler)(xact);
+ }
last_xact = &xact;
}