mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Relative dates
- eoq and soq to refer to the end and start of the quarter (thanks to David French)
This commit is contained in:
parent
e5ae145df2
commit
6e1ba161b1
5 changed files with 59 additions and 3 deletions
|
@ -38,6 +38,7 @@
|
|||
+ The configuration variable 'json.array' determines whether 'query' command
|
||||
output is enclosed by '[...]'.
|
||||
+ The duration 'm' is now interpreted as 'months', not 'minutes'.
|
||||
+ New "eoq" and "soq" dates for the end and start of quarter.
|
||||
|
||||
# Tracked Features, sorted by ID.
|
||||
+ Added feature #278, which provides a more consistent command line grammar.
|
||||
|
|
1
NEWS
1
NEWS
|
@ -24,6 +24,7 @@ New Features in taskwarrior 2.0.0
|
|||
- The done, delete, start and stop commands now allow modification to the
|
||||
task and annotations.
|
||||
- New 'columns' command to list the supported columns and formats.
|
||||
- New 'eoq' and 'soq' dates to refer to the end and start of the quarter.
|
||||
|
||||
Please refer to the ChangeLog file for full details. There are too many to
|
||||
list here.
|
||||
|
|
|
@ -600,7 +600,7 @@ task ... due:1day
|
|||
task ... due:9hrs
|
||||
|
||||
.TP
|
||||
Start of (work) week (Monday), calendar week (Sunday or Monday), month and year
|
||||
Start of (work) week (Monday), calendar week (Sunday or Monday), month, quarter and year
|
||||
.br
|
||||
task ... due:sow
|
||||
.br
|
||||
|
@ -610,10 +610,12 @@ task ... due:socw
|
|||
.br
|
||||
task ... due:som
|
||||
.br
|
||||
task ... due:soq
|
||||
.br
|
||||
task ... due:soy
|
||||
|
||||
.TP
|
||||
End of (work) week (Friday), calendar week (Saturday or Sunday), month and year
|
||||
End of (work) week (Friday), calendar week (Saturday or Sunday), month, quarter and year
|
||||
.br
|
||||
task ... due:eow
|
||||
.br
|
||||
|
@ -623,6 +625,8 @@ task ... due:eocw
|
|||
.br
|
||||
task ... due:eom
|
||||
.br
|
||||
task ... due:eoq
|
||||
.br
|
||||
task ... due:eoy
|
||||
|
||||
.TP
|
||||
|
|
40
src/Date.cpp
40
src/Date.cpp
|
@ -58,11 +58,13 @@ static const char* relatives[] =
|
|||
"eoww",
|
||||
"eocw",
|
||||
"eom",
|
||||
"eoq",
|
||||
"eoy",
|
||||
"sow",
|
||||
"soww",
|
||||
"socw",
|
||||
"som",
|
||||
"soq",
|
||||
"soy",
|
||||
"goodfriday",
|
||||
"easter",
|
||||
|
@ -877,6 +879,25 @@ bool Date::isRelativeDate (const std::string& input)
|
|||
mT = then.mT;
|
||||
return true;
|
||||
}
|
||||
else if (found == "eoq")
|
||||
{
|
||||
int m = today.month ();
|
||||
int y = today.year ();
|
||||
int q;
|
||||
if (m <= 3)
|
||||
q = 3;
|
||||
else if (m >= 4 && m <= 6)
|
||||
q = 6;
|
||||
else if (m >= 7 && m <= 9)
|
||||
q = 9;
|
||||
else
|
||||
q = 12;
|
||||
Date then (q,
|
||||
Date::daysInMonth (q, y),
|
||||
y);
|
||||
mT = then.mT;
|
||||
return true;
|
||||
}
|
||||
else if (found == "eoy")
|
||||
{
|
||||
Date then (12, 31, today.year ());
|
||||
|
@ -896,6 +917,25 @@ bool Date::isRelativeDate (const std::string& input)
|
|||
mT = then.mT;
|
||||
return true;
|
||||
}
|
||||
else if (found == "soq")
|
||||
{
|
||||
int m = today.month ();
|
||||
int y = today.year ();
|
||||
int q;
|
||||
if (m <= 3)
|
||||
q = 1;
|
||||
else if (m >= 4 && m <= 6)
|
||||
q = 4;
|
||||
else if (m >= 7 && m <= 9)
|
||||
q = 7;
|
||||
else
|
||||
q = 10;
|
||||
Date then (q,
|
||||
1,
|
||||
y);
|
||||
mT = then.mT;
|
||||
return true;
|
||||
}
|
||||
else if (found == "soy")
|
||||
{
|
||||
Date then (1, 1, today.year () + 1);
|
||||
|
|
|
@ -34,7 +34,7 @@ Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (168);
|
||||
UnitTest t (174);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -346,6 +346,16 @@ int main (int argc, char** argv)
|
|||
t.is (later.day (), 18, "later -> d = 18");
|
||||
t.is (later.year (), 2038, "later -> y = 2038");
|
||||
|
||||
// Quarters
|
||||
Date soq ("soq");
|
||||
Date eoq ("eoq");
|
||||
t.is (soq.day (), 1, "soq is the first day of a month");
|
||||
t.is (eoq.day () / 10, 3, "eoq is the 30th or 31th of a month");
|
||||
t.is (soq.month () % 3, 1, "soq month is 1, 4, 7 or 10");
|
||||
t.is (eoq.month () % 3, 0, "eoq month is 3, 6, 9 or 12");
|
||||
t.ok (soq.sameYear (now), "soq is in same year as now");
|
||||
t.ok (eoq.sameYear (now), "eoq is in same year as now");
|
||||
|
||||
// Date::sameHour
|
||||
Date r17 ("6/7/2010 01:00:00", "m/d/Y H:N:S");
|
||||
Date r18 ("6/7/2010 01:59:59", "m/d/Y H:N:S");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue