Allow the use of days of the week to "entry", e.g: "thu kfc 11".
This commit is contained in:
parent
e446b0077e
commit
b9a96e9c0d
2 changed files with 35 additions and 1 deletions
|
|
@ -1080,6 +1080,9 @@ the default."
|
|||
((looking-at "^\\s-+\\([*!]\\s-+\\)?[[(]?\\(.\\)")
|
||||
(goto-char (match-beginning 2))
|
||||
'transaction)
|
||||
((looking-at "^\\(sun\\|mon\\|tue\\|wed\\|thu\\|fri\\|sat\\)\\s-+")
|
||||
(goto-char (match-end 0))
|
||||
'entry)
|
||||
(t
|
||||
(ignore (goto-char here))))))
|
||||
|
||||
|
|
|
|||
|
|
@ -123,12 +123,33 @@ namespace {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
short string_to_day_of_week(const std::string& str)
|
||||
{
|
||||
if (str == "sun")
|
||||
return 0;
|
||||
else if (str == "mon")
|
||||
return 1;
|
||||
else if (str == "tue")
|
||||
return 2;
|
||||
else if (str == "wed")
|
||||
return 3;
|
||||
else if (str == "thu")
|
||||
return 4;
|
||||
else if (str == "fri")
|
||||
return 5;
|
||||
else if (str == "sat")
|
||||
return 6;
|
||||
assert(false);
|
||||
return -1;
|
||||
}
|
||||
|
||||
entry_template_t
|
||||
args_to_entry_template(value_t::sequence_t::const_iterator begin,
|
||||
value_t::sequence_t::const_iterator end)
|
||||
{
|
||||
regex date_mask("([0-9]+(?:[-/.][0-9]+)?(?:[-/.][0-9]+))?(?:=.*)?");
|
||||
regex dow_mask("(sun|mon|tue|wed|thu|fri|sat)");
|
||||
smatch what;
|
||||
|
||||
entry_template_t tmpl;
|
||||
|
|
@ -143,7 +164,17 @@ namespace {
|
|||
if (what.size() == 2)
|
||||
tmpl.eff_date = parse_date(what[1]);
|
||||
check_for_date = false;
|
||||
} else {
|
||||
}
|
||||
else if (check_for_date &&
|
||||
regex_match((*begin).to_string(), what, dow_mask)) {
|
||||
short dow = string_to_day_of_week(what[0]);
|
||||
date_t date = CURRENT_DATE() - date_duration(1);
|
||||
while (date.day_of_week() != dow)
|
||||
date -= date_duration(1);
|
||||
tmpl.date = date;
|
||||
check_for_date = false;
|
||||
}
|
||||
else {
|
||||
string arg = (*begin).to_string();
|
||||
|
||||
if (arg == "at") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue