Support period expressions "this/next/last week"
This commit is contained in:
parent
d9d04f62a3
commit
63b4bdaecf
1 changed files with 28 additions and 14 deletions
42
src/times.cc
42
src/times.cc
|
|
@ -851,26 +851,40 @@ date_interval_t date_parser_t::parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
case lexer_t::token_t::TOK_QUARTER: {
|
case lexer_t::token_t::TOK_QUARTER: {
|
||||||
date_t temp =
|
date_t base =
|
||||||
date_duration_t::find_nearest(today, date_duration_t::QUARTERS);
|
date_duration_t::find_nearest(today, date_duration_t::QUARTERS);
|
||||||
temp += gregorian::months(3 * adjust);
|
date_t temp;
|
||||||
inclusion_specifier =
|
if (adjust < 0) {
|
||||||
date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()),
|
temp = base + gregorian::months(3 * adjust);
|
||||||
temp.month());
|
}
|
||||||
#if 0
|
else if (adjust == 0) {
|
||||||
period.duration = date_duration_t(date_duration_t::QUARTERS, 1);
|
temp = base + gregorian::months(3);
|
||||||
#endif
|
}
|
||||||
|
else if (adjust > 0) {
|
||||||
|
base += gregorian::months(3 * adjust);
|
||||||
|
temp = base + gregorian::months(3 * adjust);
|
||||||
|
}
|
||||||
|
since_specifier = date_specifier_t(adjust < 0 ? temp : base);
|
||||||
|
until_specifier = date_specifier_t(adjust < 0 ? base : temp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case lexer_t::token_t::TOK_WEEK: {
|
case lexer_t::token_t::TOK_WEEK: {
|
||||||
date_t temp =
|
date_t base =
|
||||||
date_duration_t::find_nearest(today, date_duration_t::WEEKS);
|
date_duration_t::find_nearest(today, date_duration_t::WEEKS);
|
||||||
temp += gregorian::days(7 * adjust);
|
date_t temp;
|
||||||
inclusion_specifier = date_specifier_t(today);
|
if (adjust < 0) {
|
||||||
#if 0
|
temp = base + gregorian::days(7 * adjust);
|
||||||
period.duration = date_duration_t(date_duration_t::WEEKS, 1);
|
}
|
||||||
#endif
|
else if (adjust == 0) {
|
||||||
|
temp = base + gregorian::days(7);
|
||||||
|
}
|
||||||
|
else if (adjust > 0) {
|
||||||
|
base += gregorian::days(7 * adjust);
|
||||||
|
temp = base + gregorian::days(7 * adjust);
|
||||||
|
}
|
||||||
|
since_specifier = date_specifier_t(adjust < 0 ? temp : base);
|
||||||
|
until_specifier = date_specifier_t(adjust < 0 ? base : temp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue