mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
hints: Added :lastquarter
This commit is contained in:
parent
28fe24eb10
commit
33f1239e93
4 changed files with 25 additions and 0 deletions
|
@ -359,6 +359,7 @@ Range hints provide convenient shortcuts to date ranges:
|
|||
:year This year
|
||||
:lastweek Last week
|
||||
:lastmonth Last month
|
||||
:lastquarter Last quarter
|
||||
|
||||
|
||||
.SH CONFIGURATION FILE AND OVERRIDE OPTIONS
|
||||
|
|
|
@ -303,6 +303,7 @@ int CmdHelp (const CLI& cli)
|
|||
<< " :year This year\n"
|
||||
<< " :lastweek Last week\n"
|
||||
<< " :lastmonth Last month\n"
|
||||
<< " :lastquarter Last quarter\n"
|
||||
<< '\n'
|
||||
<< '\n';
|
||||
|
||||
|
|
|
@ -168,6 +168,28 @@ bool expandIntervalHint (
|
|||
range.end.toISOLocalExtended ()));
|
||||
return true;
|
||||
}
|
||||
else if (hint == ":lastquarter")
|
||||
{
|
||||
Datetime now;
|
||||
int y = now.year ();
|
||||
int m = now.month ();
|
||||
int q = ((m - 1) / 3) + 1;
|
||||
m = ((q - 1) * 3) + 1;
|
||||
|
||||
if (q == 1)
|
||||
{
|
||||
m = 10;
|
||||
--y;
|
||||
}
|
||||
|
||||
range.start = Datetime (y, m, 1);
|
||||
range.end = Datetime (y, m + 2, Datetime::daysInMonth (y, m + 2));
|
||||
debug (format ("Hint {1} expanded to {2} - {3}",
|
||||
hint,
|
||||
range.start.toISOLocalExtended (),
|
||||
range.end.toISOLocalExtended ()));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ void initializeEntities (CLI& cli)
|
|||
cli.entity ("hint", ":fill");
|
||||
cli.entity ("hint", ":ids");
|
||||
cli.entity ("hint", ":lastmonth");
|
||||
cli.entity ("hint", ":lastquarter");
|
||||
cli.entity ("hint", ":lastweek");
|
||||
cli.entity ("hint", ":month");
|
||||
cli.entity ("hint", ":nocolor");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue