diff --git a/src/commands/CmdHelp.cpp b/src/commands/CmdHelp.cpp index 99bd30fd..b303314d 100644 --- a/src/commands/CmdHelp.cpp +++ b/src/commands/CmdHelp.cpp @@ -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" diff --git a/src/helper.cpp b/src/helper.cpp index c5adfe55..997e7bc9 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -31,7 +31,6 @@ #include #include #include -#include // TODO Remove. #include #include @@ -99,14 +98,15 @@ bool expandIntervalHint ( { static std::map > hints { - {":yesterday", {"yesterday", "today"}}, - {":day", {"today", "tomorrow"}}, - {":week", {"socw", "eocw"}}, - {":month", {"socm", "eocm"}}, - {":quarter", {"socq", "eocq"}}, - {":year", {"socy", "eocy"}}, + {":yesterday", {"yesterday", "today"}}, + {":day", {"today", "tomorrow"}}, + {":week", {"socw", "eocw"}}, + {":month", {"socm", "eocm"}}, + {":quarter", {"socq", "eocq"}}, + {":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; } diff --git a/src/init.cpp b/src/init.cpp index 9c6c19da..626b7dd9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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");