hints: Added :lastmonth

This commit is contained in:
Paul Beckingham 2016-06-06 20:30:29 -04:00
parent e0964e9b50
commit 28fe24eb10
4 changed files with 22 additions and 0 deletions

View file

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

View file

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

View file

@ -149,6 +149,25 @@ bool expandIntervalHint (
range.end.toISOLocalExtended ()));
return true;
}
else if (hint == ":lastmonth")
{
Datetime now;
int y = now.year ();
int m = now.month () - 1;
if (m == 0)
{
m = 12;
--y;
}
range.start = Datetime (y, m, 1);
range.end = Datetime (y, m, Datetime::daysInMonth (y, m));
debug (format ("Hint {1} expanded to {2} - {3}",
hint,
range.start.toISOLocalExtended (),
range.end.toISOLocalExtended ()));
return true;
}
return false;
}

View file

@ -93,6 +93,7 @@ void initializeEntities (CLI& cli)
cli.entity ("hint", ":debug");
cli.entity ("hint", ":fill");
cli.entity ("hint", ":ids");
cli.entity ("hint", ":lastmonth");
cli.entity ("hint", ":lastweek");
cli.entity ("hint", ":month");
cli.entity ("hint", ":nocolor");