Renamed date_interval_t::end to finish

This commit is contained in:
John Wiegley 2009-11-17 21:30:07 -05:00
parent 4bc830a2c5
commit c28d828d8e
8 changed files with 58 additions and 58 deletions

View file

@ -784,7 +784,7 @@ void budget_posts::report_budget_items(const date_t& date)
assert(begin); assert(begin);
if (*begin <= date && if (*begin <= date &&
(! pair.first.end || *begin < *pair.first.end)) { (! pair.first.finish || *begin < *pair.first.finish)) {
post_t& post = *pair.second; post_t& post = *pair.second;
DEBUG("budget.generate", "Reporting budget for " DEBUG("budget.generate", "Reporting budget for "
@ -905,8 +905,8 @@ void forecast_posts::flush()
} }
date_t& begin = *(*least).first.start; date_t& begin = *(*least).first.start;
if ((*least).first.end) if ((*least).first.finish)
assert(begin < *(*least).first.end); assert(begin < *(*least).first.finish);
// If the next date in the series for this periodic posting is more than 5 // If the next date in the series for this periodic posting is more than 5
// years beyond the last valid post we generated, drop it from further // years beyond the last valid post we generated, drop it from further

View file

@ -173,8 +173,8 @@ value_t period_command(call_scope_t& args)
out << _(" start: ") << format_date(*interval.start) << std::endl; out << _(" start: ") << format_date(*interval.start) << std::endl;
else else
out << _(" start: TODAY: ") << format_date(CURRENT_DATE()) << std::endl; out << _(" start: TODAY: ") << format_date(CURRENT_DATE()) << std::endl;
if (interval.end) if (interval.finish)
out << _(" end: ") << format_date(*interval.end) << std::endl; out << _(" finish: ") << format_date(*interval.finish) << std::endl;
if (interval.skip_duration) if (interval.skip_duration)
out << _(" skip: ") << *interval.skip_duration << std::endl; out << _(" skip: ") << *interval.skip_duration << std::endl;
@ -191,8 +191,8 @@ value_t period_command(call_scope_t& args)
if (interval.start) if (interval.start)
out << _(" start: ") << format_date(*interval.start) << std::endl; out << _(" start: ") << format_date(*interval.start) << std::endl;
if (interval.end) if (interval.finish)
out << _(" end: ") << format_date(*interval.end) << std::endl; out << _(" finish: ") << format_date(*interval.finish) << std::endl;
if (interval.skip_duration) if (interval.skip_duration)
out << _(" skip: ") << *interval.skip_duration << std::endl; out << _(" skip: ") << *interval.skip_duration << std::endl;

View file

@ -263,12 +263,12 @@ query_t::parser_t::parse_query_term(query_t::lexer_t::token_t::kind_t tok_contex
node->set_right(arg1); node->set_right(arg1);
} }
if (interval.end) { if (interval.finish) {
expr_t::ptr_op_t lt = new expr_t::op_t(expr_t::op_t::O_LT); expr_t::ptr_op_t lt = new expr_t::op_t(expr_t::op_t::O_LT);
lt->set_left(ident); lt->set_left(ident);
expr_t::ptr_op_t arg1 = new expr_t::op_t(expr_t::op_t::VALUE); expr_t::ptr_op_t arg1 = new expr_t::op_t(expr_t::op_t::VALUE);
arg1->set_value(*interval.end); arg1->set_value(*interval.finish);
lt->set_right(arg1); lt->set_right(arg1);
if (node) { if (node) {

View file

@ -125,9 +125,9 @@ void report_t::normalize_options(const string& verb)
"date>=[" + to_iso_extended_string(*interval.start) + "]"; "date>=[" + to_iso_extended_string(*interval.start) + "]";
HANDLER(limit_).on(string("?normalize"), predicate); HANDLER(limit_).on(string("?normalize"), predicate);
} }
if (! HANDLED(end_) && interval.end) { if (! HANDLED(end_) && interval.finish) {
string predicate = string predicate =
"date<[" + to_iso_extended_string(*interval.end) + "]"; "date<[" + to_iso_extended_string(*interval.finish) + "]";
HANDLER(limit_).on(string("?normalize"), predicate); HANDLER(limit_).on(string("?normalize"), predicate);
} }

View file

@ -345,8 +345,8 @@ void date_interval_t::resolve_end()
"stabilize: end_of_duration = " << *end_of_duration); "stabilize: end_of_duration = " << *end_of_duration);
} }
if (end && *end_of_duration > *end) { if (finish && *end_of_duration > *finish) {
end_of_duration = end; end_of_duration = finish;
DEBUG("times.interval", DEBUG("times.interval",
"stabilize: end_of_duration reset to end: " << *end_of_duration); "stabilize: end_of_duration reset to end: " << *end_of_duration);
} }
@ -385,15 +385,15 @@ void date_interval_t::stabilize(const optional<date_t>& date)
// enough that we don't spend hundreds of thousands of loops skipping // enough that we don't spend hundreds of thousands of loops skipping
// through time. // through time.
optional<date_t> initial_start = start; optional<date_t> initial_start = start;
optional<date_t> initial_end = end; optional<date_t> initial_finish = finish;
#if defined(DEBUG_ON) #if defined(DEBUG_ON)
if (initial_start) if (initial_start)
DEBUG("times.interval", DEBUG("times.interval",
"stabilize: initial_start = " << *initial_start); "stabilize: initial_start = " << *initial_start);
if (initial_end) if (initial_finish)
DEBUG("times.interval", DEBUG("times.interval",
"stabilize: initial_end = " << *initial_end); "stabilize: initial_finish = " << *initial_finish);
#endif #endif
date_t when = start ? *start : *date; date_t when = start ? *start : *date;
@ -439,22 +439,22 @@ void date_interval_t::stabilize(const optional<date_t>& date)
start = initial_start; start = initial_start;
DEBUG("times.interval", "stabilize: start reset to initial start"); DEBUG("times.interval", "stabilize: start reset to initial start");
} }
if (initial_end && (! end || *end > *initial_end)) { if (initial_finish && (! finish || *finish > *initial_finish)) {
end = initial_end; finish = initial_finish;
DEBUG("times.interval", "stabilize: end reset to initial end"); DEBUG("times.interval", "stabilize: finish reset to initial finish");
} }
} }
aligned = true; aligned = true;
} }
// If there is no duration, then if we've reached here the date falls // If there is no duration, then if we've reached here the date falls
// between begin and end. // between start and finish.
if (! duration) { if (! duration) {
DEBUG("times.interval", "stabilize: there was no duration given"); DEBUG("times.interval", "stabilize: there was no duration given");
if (! start && ! end) if (! start && ! finish)
throw_(date_error, throw_(date_error,
_("Invalid date interval: neither start, nor end, nor duration")); _("Invalid date interval: neither start, nor finish, nor duration"));
} else { } else {
resolve_end(); resolve_end();
} }
@ -464,9 +464,9 @@ bool date_interval_t::find_period(const date_t& date)
{ {
stabilize(date); stabilize(date);
if (end && date > *end) { if (finish && date > *finish) {
DEBUG("times.interval", DEBUG("times.interval",
"false: date [" << date << "] > end [" << *end << "]"); "false: date [" << date << "] > finish [" << *finish << "]");
return false; return false;
} }
@ -503,7 +503,7 @@ bool date_interval_t::find_period(const date_t& date)
DEBUG("times.interval", "scan = " << scan); DEBUG("times.interval", "scan = " << scan);
DEBUG("times.interval", "end_of_scan = " << end_of_scan); DEBUG("times.interval", "end_of_scan = " << end_of_scan);
while (date >= scan && (! end || scan < *end)) { while (date >= scan && (! finish || scan < *finish)) {
if (date < end_of_scan) { if (date < end_of_scan) {
start = scan; start = scan;
end_of_duration = end_of_scan; end_of_duration = end_of_scan;
@ -535,7 +535,7 @@ date_interval_t& date_interval_t::operator++()
assert(next); assert(next);
if (end && *next >= *end) { if (finish && *next >= *finish) {
start = none; start = none;
} else { } else {
start = *next; start = *next;
@ -587,7 +587,7 @@ namespace {
string& word, string& word,
date_interval_t& interval, date_interval_t& interval,
bool look_for_start = true, bool look_for_start = true,
bool look_for_end = true) bool look_for_finish = true)
{ {
string type; string type;
@ -602,12 +602,12 @@ namespace {
} }
date_t start = CURRENT_DATE(); date_t start = CURRENT_DATE();
date_t end; date_t finish;
bool parse_specifier = false; bool parse_specifier = false;
optional<date_interval_t::duration_t> duration; optional<date_interval_t::duration_t> duration;
assert(look_for_start || look_for_end); assert(look_for_start || look_for_finish);
if (word == _("year")) { if (word == _("year")) {
duration = date_interval_t::duration_t(date_interval_t::duration_t::YEARS, 1); duration = date_interval_t::duration_t(date_interval_t::duration_t::YEARS, 1);
@ -625,21 +625,21 @@ namespace {
} }
if (parse_specifier) if (parse_specifier)
parse_inclusion_specifier(word, &start, &end); parse_inclusion_specifier(word, &start, &finish);
else else
end = duration->add(start); finish = duration->add(start);
if (type == _("last") && duration) { if (type == _("last") && duration) {
start = duration->subtract(start); start = duration->subtract(start);
end = duration->subtract(end); finish = duration->subtract(finish);
} }
else if (type == _("next") && duration) { else if (type == _("next") && duration) {
start = duration->add(start); start = duration->add(start);
end = duration->add(end); finish = duration->add(finish);
} }
if (look_for_start && is_valid(start)) interval.start = start; if (look_for_start && is_valid(start)) interval.start = start;
if (look_for_end && is_valid(end)) interval.end = end; if (look_for_finish && is_valid(finish)) interval.finish = finish;
} }
} }
@ -723,10 +723,10 @@ void date_interval_t::parse(std::istream& in)
} }
else { else {
// otherwise, it should be an explicit date // otherwise, it should be an explicit date
date_t b, e; date_t s, f;
parse_inclusion_specifier(word, &b, &e); parse_inclusion_specifier(word, &s, &f);
start = b; start = s;
end = e; finish = f;
} }
} }
@ -738,23 +738,23 @@ void date_interval_t::parse(std::istream& in)
while (start->day_of_week() != *wday) while (start->day_of_week() != *wday)
*start -= gregorian::days(1); *start -= gregorian::days(1);
if (! end) if (! finish)
end = *start + gregorian::days(1); finish = *start + gregorian::days(1);
} else { } else {
bool overwrite_end = false; bool overwrite_finish = false;
if (year) { if (year) {
start = date_t(*year, 1, 1); start = date_t(*year, 1, 1);
if (! end) { if (! finish) {
end = *start + gregorian::years(1); finish = *start + gregorian::years(1);
overwrite_end = true; overwrite_finish = true;
} }
} }
if (mon) { if (mon) {
start = date_t(start->year(), *mon, 1); start = date_t(start->year(), *mon, 1);
if (! end || overwrite_end) if (! finish || overwrite_finish)
end = *start + gregorian::months(1); finish = *start + gregorian::months(1);
} }
} }
} }

View file

@ -219,7 +219,7 @@ public:
optional<date_t> next; optional<date_t> next;
optional<duration_t> duration; optional<duration_t> duration;
optional<date_t> end_of_duration; optional<date_t> end_of_duration;
optional<date_t> end; optional<date_t> finish;
explicit date_interval_t() : aligned(false), factor(1) { explicit date_interval_t() : aligned(false), factor(1) {
TRACE_CTOR(date_interval_t, ""); TRACE_CTOR(date_interval_t, "");
@ -236,7 +236,7 @@ public:
next(other.next), next(other.next),
duration(other.duration), duration(other.duration),
end_of_duration(other.end_of_duration), end_of_duration(other.end_of_duration),
end(other.end) { finish(other.finish) {
TRACE_CTOR(date_interval_t, "copy"); TRACE_CTOR(date_interval_t, "copy");
} }
~date_interval_t() throw() { ~date_interval_t() throw() {
@ -295,7 +295,7 @@ private:
ar & next; ar & next;
ar & duration; ar & duration;
ar & end_of_duration; ar & end_of_duration;
ar & end; ar & finish;
} }
#endif // HAVE_BOOST_SERIALIZATION #endif // HAVE_BOOST_SERIALIZATION
}; };

View file

@ -4,7 +4,7 @@ period --now=2010/11/01 12/01
global details => global details =>
start: 09-Dec-01 start: 09-Dec-01
end: 09-Dec-02 finish: 09-Dec-02
factor: 1 factor: 1
>>>2 >>>2
=== 0 === 0
@ -14,7 +14,7 @@ period --now=2010/11/01 10/01
global details => global details =>
start: 10-Oct-01 start: 10-Oct-01
end: 10-Oct-02 finish: 10-Oct-02
factor: 1 factor: 1
>>>2 >>>2
=== 0 === 0
@ -24,7 +24,7 @@ period --now=2010/11/01 2009/10
global details => global details =>
start: 09-Oct-01 start: 09-Oct-01
end: 09-Nov-01 finish: 09-Nov-01
factor: 1 factor: 1
>>>2 >>>2
=== 0 === 0
@ -34,7 +34,7 @@ period --now=2010/11/01 2009/10/01
global details => global details =>
start: 09-Oct-01 start: 09-Oct-01
end: 09-Oct-02 finish: 09-Oct-02
factor: 1 factor: 1
>>>2 >>>2
=== 0 === 0
@ -44,7 +44,7 @@ period --now=2010/11/01 2009
global details => global details =>
start: 09-Jan-01 start: 09-Jan-01
end: 10-Jan-01 finish: 10-Jan-01
factor: 1 factor: 1
>>>2 >>>2
=== 0 === 0

View file

@ -4,7 +4,7 @@ period june 2008
global details => global details =>
start: 08-Jun-01 start: 08-Jun-01
end: 08-Jul-01 finish: 08-Jul-01
factor: 1 factor: 1
>>>2 >>>2
=== 0 === 0