hints: Added :lastyear

This commit is contained in:
Paul Beckingham 2016-06-06 20:32:24 -04:00
parent 33f1239e93
commit 12dfee1bc8
4 changed files with 14 additions and 0 deletions

View file

@ -360,6 +360,7 @@ Range hints provide convenient shortcuts to date ranges:
:lastweek Last week
:lastmonth Last month
:lastquarter Last quarter
:lastyear Last year
.SH CONFIGURATION FILE AND OVERRIDE OPTIONS

View file

@ -304,6 +304,7 @@ int CmdHelp (const CLI& cli)
<< " :lastweek Last week\n"
<< " :lastmonth Last month\n"
<< " :lastquarter Last quarter\n"
<< " :lastyear Last year\n"
<< '\n'
<< '\n';

View file

@ -190,6 +190,17 @@ bool expandIntervalHint (
range.end.toISOLocalExtended ()));
return true;
}
else if (hint == ":lastyear")
{
Datetime now;
range.start = Datetime (now.year () - 1, 1, 1);
range.end = Datetime (now.year () - 1, 12, 31);
debug (format ("Hint {1} expanded to {2} - {3}",
hint,
range.start.toISOLocalExtended (),
range.end.toISOLocalExtended ()));
return true;
}
return false;
}

View file

@ -96,6 +96,7 @@ void initializeEntities (CLI& cli)
cli.entity ("hint", ":lastmonth");
cli.entity ("hint", ":lastquarter");
cli.entity ("hint", ":lastweek");
cli.entity ("hint", ":lastyear");
cli.entity ("hint", ":month");
cli.entity ("hint", ":nocolor");
cli.entity ("hint", ":quarter");