summaryrefslogtreecommitdiff
path: root/src/times.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-02-28 02:34:37 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-02-28 02:34:37 -0600
commit6adfcc8469e3d526f4bcb0971b49efb490ad6401 (patch)
tree4185b2ebbd668b7ded2808a9cd8a5edccf39d8bc /src/times.cc
parent887f429ae40934c145e03b03cc452e6af4457c0f (diff)
downloadfork-ledger-6adfcc8469e3d526f4bcb0971b49efb490ad6401.tar.gz
fork-ledger-6adfcc8469e3d526f4bcb0971b49efb490ad6401.tar.bz2
fork-ledger-6adfcc8469e3d526f4bcb0971b49efb490ad6401.zip
Rewrite the way interval reports are generated
Diffstat (limited to 'src/times.cc')
-rw-r--r--src/times.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/times.cc b/src/times.cc
index dd10a508..9712c2ee 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -1305,7 +1305,7 @@ void date_interval_t::stabilize(const optional<date_t>& date)
date_interval_t next_interval(*this);
++next_interval;
- if (next_interval.start && *next_interval.start < *date) {
+ if (next_interval.start && *next_interval.start <= *date) {
*this = next_interval;
} else {
end_of_duration = none;
@@ -1355,7 +1355,8 @@ void date_interval_t::stabilize(const optional<date_t>& date)
}
}
-bool date_interval_t::find_period(const date_t& date)
+bool date_interval_t::find_period(const date_t& date,
+ const bool allow_shift)
{
stabilize(date);
@@ -1405,9 +1406,6 @@ bool date_interval_t::find_period(const date_t& date)
#endif
while (date >= scan && (! finish || scan < *finish)) {
- DEBUG("times.interval", "date = " << date);
- DEBUG("times.interval", "end_of_scan = " << end_of_scan);
-
if (date < end_of_scan) {
start = scan;
end_of_duration = end_of_scan;
@@ -1420,9 +1418,15 @@ bool date_interval_t::find_period(const date_t& date)
return true;
}
+ else if (! allow_shift) {
+ break;
+ }
scan = duration->add(scan);
end_of_scan = duration->add(scan);
+
+ DEBUG("times.interval", "scan = " << scan);
+ DEBUG("times.interval", "end_of_scan = " << end_of_scan);
}
DEBUG("times.interval", "false: failed scan");