summaryrefslogtreecommitdiff
path: root/src/times.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/times.cc')
-rw-r--r--src/times.cc27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/times.cc b/src/times.cc
index e3ccaff8..963639f1 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -224,7 +224,7 @@ namespace {
when = date_t(year ? *year : CURRENT_DATE().year(),
when.month(), when.day());
- if (when.month() > CURRENT_DATE().month())
+ if (! year && when.month() > CURRENT_DATE().month())
when -= gregorian::years(1);
}
}
@@ -824,15 +824,6 @@ date_interval_t date_parser_t::parse()
break;
}
- case lexer_t::token_t::TOK_MONTH: {
- date_t temp(today);
- temp += gregorian::months(adjust);
- inclusion_specifier =
- date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()),
- temp.month());
- break;
- }
-
case lexer_t::token_t::TOK_WEEK: {
date_t temp =
date_duration_t::find_nearest(today, date_duration_t::WEEKS);
@@ -852,10 +843,15 @@ date_interval_t date_parser_t::parse()
}
default:
- tok.unexpected();
+ case lexer_t::token_t::TOK_MONTH: {
+ date_t temp(today);
+ temp += gregorian::months(adjust);
+ inclusion_specifier =
+ date_specifier_t(static_cast<date_specifier_t::year_type>(temp.year()),
+ temp.month());
break;
}
- break;
+ }
}
case lexer_t::token_t::TOK_TODAY:
@@ -1321,10 +1317,13 @@ date_parser_t::lexer_t::token_t date_parser_t::lexer_t::next_token()
catch (...) {}
}
+ start = begin;
+
string term;
bool alnum = std::isalnum(*begin);
- for (start = begin; (begin != end && ! std::isspace(*begin) &&
- alnum == std::isalnum(*begin)); begin++)
+ for (; (begin != end && ! std::isspace(*begin) &&
+ ((alnum && static_cast<bool>(std::isalnum(*begin))) ||
+ (! alnum && ! static_cast<bool>(std::isalnum(*begin))))); begin++)
term.push_back(*begin);
if (! term.empty()) {