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
|
@ -31,7 +31,6 @@
|
|||
#include <Duration.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <iostream> // TODO Remove.
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
@ -99,14 +98,15 @@ bool expandIntervalHint (
|
|||
{
|
||||
static std::map <std::string, std::vector <std::string>> 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue