summaryrefslogtreecommitdiff
path: root/src/times.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-14 04:27:15 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-14 04:27:15 -0400
commit388044dec99a9ed27bfdefe3c07234e4b27b3997 (patch)
treefc4e843d00db6ed859de565333d55b471f7c0334 /src/times.cc
parente50abb56455791774bf75e786234e8d2a637d63a (diff)
downloadfork-ledger-388044dec99a9ed27bfdefe3c07234e4b27b3997.tar.gz
fork-ledger-388044dec99a9ed27bfdefe3c07234e4b27b3997.tar.bz2
fork-ledger-388044dec99a9ed27bfdefe3c07234e4b27b3997.zip
Fixed the way interval_t objects are initialized
Diffstat (limited to 'src/times.cc')
-rw-r--r--src/times.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/times.cc b/src/times.cc
index 77968127..4ea7389b 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -118,21 +118,19 @@ date_t parse_date(const char * str, int current_year)
return gregorian::date_from_tm(when);
}
-date_t interval_t::first(const optional<date_t>& moment) const
+date_t interval_t::first(const optional<date_t>& moment)
{
- if (! is_valid(begin))
- throw_(date_error,
- "Use of interval_t::first() with specifying a range start");
+ if (! is_valid(begin)) {
+ // Find an efficient starting point for the upcoming while loop. We want
+ // a date early enough that the range will be correct, but late enough
+ // that we don't spend hundreds of thousands of loops skipping through
+ // time.
+ begin = date_t(moment->year(), gregorian::Jan, 1);
+ }
date_t quant(begin);
- if (moment && *moment > quant) {
- // Find an efficient starting point for the upcoming while loop.
- // We want a date early enough that the range will be correct, but
- // late enough that we don't spend hundreds of thousands of loops
- // skipping through time.
-
- date_t quant(moment->year(), gregorian::Jan, 1);
+ if (moment && *moment >= quant) {
date_t temp;
while (*moment >= (temp = increment(quant))) {
if (quant == temp)