mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
init: Added :lastweek hint
This commit is contained in:
parent
b5cf680730
commit
0569071a5d
3 changed files with 20 additions and 7 deletions
|
@ -210,6 +210,7 @@ int CmdHelp (const CLI& cli)
|
||||||
<< " :month This month\n"
|
<< " :month This month\n"
|
||||||
<< " :quarter This quarter\n"
|
<< " :quarter This quarter\n"
|
||||||
<< " :year This year\n"
|
<< " :year This year\n"
|
||||||
|
<< " :lastweek Last week\n"
|
||||||
<< '\n'
|
<< '\n'
|
||||||
<< " :fill Expand time to fill surrounding available gap\n"
|
<< " :fill Expand time to fill surrounding available gap\n"
|
||||||
<< " Only functions when exclusions are provided\n"
|
<< " Only functions when exclusions are provided\n"
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream> // TODO Remove.
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -107,6 +106,7 @@ bool expandIntervalHint (
|
||||||
{":year", {"socy", "eocy"}},
|
{":year", {"socy", "eocy"}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Some hints are just synonyms.
|
||||||
if (hints.find (hint) != hints.end ())
|
if (hints.find (hint) != hints.end ())
|
||||||
{
|
{
|
||||||
start = hints[hint][0];
|
start = hints[hint][0];
|
||||||
|
@ -114,6 +114,17 @@ bool expandIntervalHint (
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ void initializeEntities (CLI& cli)
|
||||||
cli.entity ("hint", ":month");
|
cli.entity ("hint", ":month");
|
||||||
cli.entity ("hint", ":quarter");
|
cli.entity ("hint", ":quarter");
|
||||||
cli.entity ("hint", ":year");
|
cli.entity ("hint", ":year");
|
||||||
|
cli.entity ("hint", ":lastweek");
|
||||||
cli.entity ("hint", ":fill");
|
cli.entity ("hint", ":fill");
|
||||||
cli.entity ("hint", ":color");
|
cli.entity ("hint", ":color");
|
||||||
cli.entity ("hint", ":nocolor");
|
cli.entity ("hint", ":nocolor");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue