diff --git a/AUTHORS b/AUTHORS index 04cc47d85..466af3427 100644 --- a/AUTHORS +++ b/AUTHORS @@ -159,4 +159,5 @@ suggestions: Jim B Jake Bell Florian Hollerweger + Thomas Sullivan diff --git a/ChangeLog b/ChangeLog index 54e8e2af5..461aedfd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ Features (thanks to Michelle Crane). + Added Feature #953, which includes the total number of blocked and blocking tasks to the 'statistics' command output (thanks to T. Charles Yun). + + Added Feature #1039, which adds new date shortcuts, 'socm' and 'eocm', + meaning start and end of current month (thanks to Thomas Sullivan, + Louis-Claude Canon). + Added Feature #1061, which allows the 'columns' command to use a search string for the column name (thanks to Uli Martens). + Added Feature #1069, which gives a clearer error when a UDA diff --git a/NEWS b/NEWS index 7dfdd8b47..f8f957ae8 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ New Features in taskwarrior 2.2.0 all, that they were modified. - Statistics now report total number of blocked and blocking tasks. - The 'columns' command now supports search term for the column name. + - New date shortcuts, 'socm' and 'eocm', meaning start and end of current + month. New commands in taskwarrior 2.2.0 diff --git a/src/Date.cpp b/src/Date.cpp index 13256e417..e4b87df7f 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -56,12 +56,14 @@ static const char* relatives[] = "eow", "eoww", "eocw", + "eocm", "eom", "eoq", "eoy", "sow", "soww", "socw", + "socm", "som", "soq", "soy", @@ -828,7 +830,8 @@ bool Date::isRelativeDate (const std::string& input) found == "eocw" || found == "sow" || found == "soww" || - found == "socw") + found == "socw" || + found == "socm") { if (found == "eow" || found == "eoww") dow = 5; @@ -847,6 +850,9 @@ bool Date::isRelativeDate (const std::string& input) else today += (dow - today.dayOfWeek ()) * 86400; + if (found == "socm") + today -= (today.day () - 1) * 86400; + int m, d, y; today.toMDY (m, d, y); Date then (m, d, y); @@ -878,7 +884,7 @@ bool Date::isRelativeDate (const std::string& input) _t = then._t - 86400; return true; } - else if (found == "eom") + else if (found == "eom" || found == "eocm") { Date then (today.month (), daysInMonth (today.month (), today.year ()), diff --git a/test/date.t.cpp b/test/date.t.cpp index f8944f822..055c635de 100644 --- a/test/date.t.cpp +++ b/test/date.t.cpp @@ -35,7 +35,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (179); + UnitTest t (181); try { @@ -324,26 +324,32 @@ int main (int argc, char** argv) Date r11 ("eow"); t.ok (r11 < now + (8 * 86400), "eow < 7 days away"); - Date r20 ("eocw"); - t.ok (r20 < now + (8 * 86400), "eocw < 7 days away"); + Date r12 ("eocw"); + t.ok (r12 < now + (8 * 86400), "eocw < 7 days away"); - Date r12 ("eom"); - t.ok (r12.sameMonth (now), "eom in same month as now"); + Date r13 ("eom"); + t.ok (r13.sameMonth (now), "eom in same month as now"); - Date r13 ("eoy"); - t.ok (r13.sameYear (now), "eoy in same year as now"); + Date r14 ("eocm"); + t.ok (r14.sameMonth (now), "eocm in same month as now"); - Date r14 ("sow"); - t.ok (r14 < now + (8 * 86400), "sow < 7 days away"); + Date r15 ("eoy"); + t.ok (r15.sameYear (now), "eoy in same year as now"); - Date r21 ("socw"); - t.ok (r21 < now + (8 * 86400), "sow < 7 days away"); + Date r16 ("sow"); + t.ok (r16 < now + (8 * 86400), "sow < 7 days away"); - Date r15 ("som"); - t.notok (r15.sameMonth (now), "som not in same month as now"); + Date r23 ("socw"); + t.ok (r23 < now + (8 * 86400), "sow < 7 days away"); - Date r16 ("soy"); - t.notok (r16.sameYear (now), "soy not in same year as now"); + Date r17 ("som"); + t.notok (r17.sameMonth (now), "som not in same month as now"); + + Date r18 ("socm"); + t.ok (r18.sameMonth (now), "socm in same month as now"); + + Date r19 ("soy"); + t.notok (r19.sameYear (now), "soy not in same year as now"); Date first ("1st"); t.notok (first.sameMonth (now), "1st not in same month as now"); @@ -372,34 +378,34 @@ int main (int argc, char** argv) 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"); - t.ok (r17.sameHour (r18), "two dates within the same hour"); + Date r20 ("6/7/2010 01:00:00", "m/d/Y H:N:S"); + Date r21 ("6/7/2010 01:59:59", "m/d/Y H:N:S"); + t.ok (r20.sameHour (r21), "two dates within the same hour"); - Date r19 ("6/7/2010 00:59:59", "m/d/Y H:N:S"); - t.notok (r17.sameHour (r19), "two dates not within the same hour"); + Date r22 ("6/7/2010 00:59:59", "m/d/Y H:N:S"); + t.notok (r20.sameHour (r22), "two dates not within the same hour"); // Date::operator- - Date r22 (1234567890); - t.is ((r22 - 1).toEpoch (), 1234567889, "1234567890 - 1 = 1234567889"); + Date r25 (1234567890); + t.is ((r25 - 1).toEpoch (), 1234567889, "1234567890 - 1 = 1234567889"); // Date::operator-- - Date r23 (11, 7, 2010, 23, 59, 59); - r23--; - t.is (r23.toString ("YMDHNS"), "20101106235959", "decrement across fall DST boundary"); + Date r26 (11, 7, 2010, 23, 59, 59); + r26--; + t.is (r26.toString ("YMDHNS"), "20101106235959", "decrement across fall DST boundary"); - Date r24 (3, 14, 2010, 23, 59, 59); - r24--; - t.is (r24.toString ("YMDHNS"), "20100313235959", "decrement across spring DST boundary"); + Date r27 (3, 14, 2010, 23, 59, 59); + r27--; + t.is (r27.toString ("YMDHNS"), "20100313235959", "decrement across spring DST boundary"); // Date::operator++ - Date r25 (11, 6, 2010, 23, 59, 59); - r25++; - t.is (r25.toString ("YMDHNS"), "20101107235959", "increment across fall DST boundary"); + Date r28 (11, 6, 2010, 23, 59, 59); + r28++; + t.is (r28.toString ("YMDHNS"), "20101107235959", "increment across fall DST boundary"); - Date r26 (3, 13, 2010, 23, 59, 59); - r26++; - t.is (r26.toString ("YMDHNS"), "20100314235959", "increment across spring DST boundary"); + Date r29 (3, 13, 2010, 23, 59, 59); + r29++; + t.is (r29.toString ("YMDHNS"), "20100314235959", "increment across spring DST boundary"); } catch (const std::string& e)