mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
hints: Added :lastmonth
This commit is contained in:
parent
e0964e9b50
commit
28fe24eb10
4 changed files with 22 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue