- 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).
This commit is contained in:
Paul Beckingham
2012-12-01 14:22:09 -05:00
parent 12b12c3a62
commit 4e03832b68
5 changed files with 54 additions and 36 deletions

View File

@@ -159,4 +159,5 @@ suggestions:
Jim B Jim B
Jake Bell Jake Bell
Florian Hollerweger Florian Hollerweger
Thomas Sullivan

View File

@@ -7,6 +7,9 @@ Features
(thanks to Michelle Crane). (thanks to Michelle Crane).
+ Added Feature #953, which includes the total number of blocked and blocking + Added Feature #953, which includes the total number of blocked and blocking
tasks to the 'statistics' command output (thanks to T. Charles Yun). 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 + Added Feature #1061, which allows the 'columns' command to use a search
string for the column name (thanks to Uli Martens). string for the column name (thanks to Uli Martens).
+ Added Feature #1069, which gives a clearer error when a UDA + Added Feature #1069, which gives a clearer error when a UDA

2
NEWS
View File

@@ -9,6 +9,8 @@ New Features in taskwarrior 2.2.0
all, that they were modified. all, that they were modified.
- Statistics now report total number of blocked and blocking tasks. - Statistics now report total number of blocked and blocking tasks.
- The 'columns' command now supports search term for the column name. - 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 New commands in taskwarrior 2.2.0

View File

@@ -56,12 +56,14 @@ static const char* relatives[] =
"eow", "eow",
"eoww", "eoww",
"eocw", "eocw",
"eocm",
"eom", "eom",
"eoq", "eoq",
"eoy", "eoy",
"sow", "sow",
"soww", "soww",
"socw", "socw",
"socm",
"som", "som",
"soq", "soq",
"soy", "soy",
@@ -828,7 +830,8 @@ bool Date::isRelativeDate (const std::string& input)
found == "eocw" || found == "eocw" ||
found == "sow" || found == "sow" ||
found == "soww" || found == "soww" ||
found == "socw") found == "socw" ||
found == "socm")
{ {
if (found == "eow" || found == "eoww") if (found == "eow" || found == "eoww")
dow = 5; dow = 5;
@@ -847,6 +850,9 @@ bool Date::isRelativeDate (const std::string& input)
else else
today += (dow - today.dayOfWeek ()) * 86400; today += (dow - today.dayOfWeek ()) * 86400;
if (found == "socm")
today -= (today.day () - 1) * 86400;
int m, d, y; int m, d, y;
today.toMDY (m, d, y); today.toMDY (m, d, y);
Date then (m, d, y); Date then (m, d, y);
@@ -878,7 +884,7 @@ bool Date::isRelativeDate (const std::string& input)
_t = then._t - 86400; _t = then._t - 86400;
return true; return true;
} }
else if (found == "eom") else if (found == "eom" || found == "eocm")
{ {
Date then (today.month (), Date then (today.month (),
daysInMonth (today.month (), today.year ()), daysInMonth (today.month (), today.year ()),

View File

@@ -35,7 +35,7 @@ Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
UnitTest t (179); UnitTest t (181);
try try
{ {
@@ -324,26 +324,32 @@ int main (int argc, char** argv)
Date r11 ("eow"); Date r11 ("eow");
t.ok (r11 < now + (8 * 86400), "eow < 7 days away"); t.ok (r11 < now + (8 * 86400), "eow < 7 days away");
Date r20 ("eocw"); Date r12 ("eocw");
t.ok (r20 < now + (8 * 86400), "eocw < 7 days away"); t.ok (r12 < now + (8 * 86400), "eocw < 7 days away");
Date r12 ("eom"); Date r13 ("eom");
t.ok (r12.sameMonth (now), "eom in same month as now"); t.ok (r13.sameMonth (now), "eom in same month as now");
Date r13 ("eoy"); Date r14 ("eocm");
t.ok (r13.sameYear (now), "eoy in same year as now"); t.ok (r14.sameMonth (now), "eocm in same month as now");
Date r14 ("sow"); Date r15 ("eoy");
t.ok (r14 < now + (8 * 86400), "sow < 7 days away"); t.ok (r15.sameYear (now), "eoy in same year as now");
Date r21 ("socw"); Date r16 ("sow");
t.ok (r21 < now + (8 * 86400), "sow < 7 days away"); t.ok (r16 < now + (8 * 86400), "sow < 7 days away");
Date r15 ("som"); Date r23 ("socw");
t.notok (r15.sameMonth (now), "som not in same month as now"); t.ok (r23 < now + (8 * 86400), "sow < 7 days away");
Date r16 ("soy"); Date r17 ("som");
t.notok (r16.sameYear (now), "soy not in same year as now"); 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"); Date first ("1st");
t.notok (first.sameMonth (now), "1st not in same month as now"); 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"); t.ok (eoq.sameYear (now), "eoq is in same year as now");
// Date::sameHour // Date::sameHour
Date r17 ("6/7/2010 01:00:00", "m/d/Y H:N:S"); Date r20 ("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"); Date r21 ("6/7/2010 01:59:59", "m/d/Y H:N:S");
t.ok (r17.sameHour (r18), "two dates within the same hour"); 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"); Date r22 ("6/7/2010 00:59:59", "m/d/Y H:N:S");
t.notok (r17.sameHour (r19), "two dates not within the same hour"); t.notok (r20.sameHour (r22), "two dates not within the same hour");
// Date::operator- // Date::operator-
Date r22 (1234567890); Date r25 (1234567890);
t.is ((r22 - 1).toEpoch (), 1234567889, "1234567890 - 1 = 1234567889"); t.is ((r25 - 1).toEpoch (), 1234567889, "1234567890 - 1 = 1234567889");
// Date::operator-- // Date::operator--
Date r23 (11, 7, 2010, 23, 59, 59); Date r26 (11, 7, 2010, 23, 59, 59);
r23--; r26--;
t.is (r23.toString ("YMDHNS"), "20101106235959", "decrement across fall DST boundary"); t.is (r26.toString ("YMDHNS"), "20101106235959", "decrement across fall DST boundary");
Date r24 (3, 14, 2010, 23, 59, 59); Date r27 (3, 14, 2010, 23, 59, 59);
r24--; r27--;
t.is (r24.toString ("YMDHNS"), "20100313235959", "decrement across spring DST boundary"); t.is (r27.toString ("YMDHNS"), "20100313235959", "decrement across spring DST boundary");
// Date::operator++ // Date::operator++
Date r25 (11, 6, 2010, 23, 59, 59); Date r28 (11, 6, 2010, 23, 59, 59);
r25++; r28++;
t.is (r25.toString ("YMDHNS"), "20101107235959", "increment across fall DST boundary"); t.is (r28.toString ("YMDHNS"), "20101107235959", "increment across fall DST boundary");
Date r26 (3, 13, 2010, 23, 59, 59); Date r29 (3, 13, 2010, 23, 59, 59);
r26++; r29++;
t.is (r26.toString ("YMDHNS"), "20100314235959", "increment across spring DST boundary"); t.is (r29.toString ("YMDHNS"), "20100314235959", "increment across spring DST boundary");
} }
catch (const std::string& e) catch (const std::string& e)