diff --git a/ChangeLog b/ChangeLog index d2c85d595..802a2e3e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/NEWS b/NEWS index bc5fc3e8e..a023bf3dd 100644 --- a/NEWS +++ b/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. diff --git a/doc/man/task.1.in b/doc/man/task.1.in index 2262b71ea..179d260c1 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -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 diff --git a/src/Date.cpp b/src/Date.cpp index 828c9e2d9..b9522dd99 100644 --- a/src/Date.cpp +++ b/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); diff --git a/test/date.t.cpp b/test/date.t.cpp index 26c5d0f81..1570ce816 100644 --- a/test/date.t.cpp +++ b/test/date.t.cpp @@ -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");