diff --git a/doc/man/timew.1.in b/doc/man/timew.1.in index 10f73e91..314b66a7 100644 --- a/doc/man/timew.1.in +++ b/doc/man/timew.1.in @@ -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 diff --git a/src/commands/CmdHelp.cpp b/src/commands/CmdHelp.cpp index 7cacc8eb..57c6802a 100644 --- a/src/commands/CmdHelp.cpp +++ b/src/commands/CmdHelp.cpp @@ -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'; diff --git a/src/helper.cpp b/src/helper.cpp index 95b21b89..f96f0c00 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -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; } diff --git a/src/init.cpp b/src/init.cpp index ddf4a32d..eaeefc14 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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");