init: Added :lastweek hint

This commit is contained in:
Paul Beckingham 2016-05-01 16:13:06 -04:00
parent b5cf680730
commit 0569071a5d
3 changed files with 20 additions and 7 deletions

View file

@ -210,6 +210,7 @@ int CmdHelp (const CLI& cli)
<< " :month This month\n"
<< " :quarter This quarter\n"
<< " :year This year\n"
<< " :lastweek Last week\n"
<< '\n'
<< " :fill Expand time to fill surrounding available gap\n"
<< " Only functions when exclusions are provided\n"

View file

@ -31,7 +31,6 @@
#include <Duration.h>
#include <sstream>
#include <iomanip>
#include <iostream> // TODO Remove.
#include <map>
#include <vector>
@ -107,6 +106,7 @@ bool expandIntervalHint (
{":year", {"socy", "eocy"}},
};
// Some hints are just synonyms.
if (hints.find (hint) != hints.end ())
{
start = hints[hint][0];
@ -114,6 +114,17 @@ bool expandIntervalHint (
return true;
}
// Some require math.
if (hint == ":lastweek")
{
Datetime socw ("socw");
Datetime eocw ("eocw");
socw -= 7 * 86400;
eocw -= 7 * 86400;
start = socw.toString ("Y-M-D");
end = eocw.toString ("Y-M-D");
}
return false;
}

View file

@ -91,6 +91,7 @@ void initializeEntities (CLI& cli)
cli.entity ("hint", ":month");
cli.entity ("hint", ":quarter");
cli.entity ("hint", ":year");
cli.entity ("hint", ":lastweek");
cli.entity ("hint", ":fill");
cli.entity ("hint", ":color");
cli.entity ("hint", ":nocolor");