diff options
author | John Wiegley <johnw@newartisans.com> | 2009-03-23 19:21:27 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-03-23 19:21:27 -0400 |
commit | 0918f9d4f5ed98eb8dc9958a7ef63e4d4a53eff7 (patch) | |
tree | f6d2bfbad49ed9ae54826ee53492ff4b44e90f56 /src/times.cc | |
parent | 8b175c7d6d807f84543782f7386f8e9d29090d73 (diff) | |
download | fork-ledger-0918f9d4f5ed98eb8dc9958a7ef63e4d4a53eff7.tar.gz fork-ledger-0918f9d4f5ed98eb8dc9958a7ef63e4d4a53eff7.tar.bz2 fork-ledger-0918f9d4f5ed98eb8dc9958a7ef63e4d4a53eff7.zip |
Don't instantiate duration_t using default ctor
Diffstat (limited to 'src/times.cc')
-rw-r--r-- | src/times.cc | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/times.cc b/src/times.cc index 5371b1da..360f786a 100644 --- a/src/times.cc +++ b/src/times.cc @@ -513,7 +513,7 @@ namespace { date_t end; bool parse_specifier = false; - date_interval_t::duration_t duration; + optional<date_interval_t::duration_t> duration; assert(look_for_start || look_for_end); @@ -531,22 +531,23 @@ namespace { else { parse_specifier = true; } - end = date_interval_t::add_duration(start, duration); if (parse_specifier) parse_inclusion_specifier(word, &start, &end); + else + end = date_interval_t::add_duration(start, *duration); - if (type == _("last")) { - start = date_interval_t::subtract_duration(start, duration); - end = date_interval_t::subtract_duration(end, duration); + if (type == _("last") && duration) { + start = date_interval_t::subtract_duration(start, *duration); + end = date_interval_t::subtract_duration(end, *duration); } - else if (type == _("next")) { - start = date_interval_t::add_duration(start, duration); - end = date_interval_t::add_duration(end, duration); + else if (type == _("next") && duration) { + start = date_interval_t::add_duration(start, *duration); + end = date_interval_t::add_duration(end, *duration); } - if (look_for_start) interval.start = start; - if (look_for_end) interval.end = end; + if (look_for_start && is_valid(start)) interval.start = start; + if (look_for_end && is_valid(end)) interval.end = end; } } |