Feature #446 - start of {week, month, year}

- Bug fix for som and soy.
- Added synonyms soww and eoww for sow and eow.
- Added start/end of calendar week: socw and eocw.
This commit is contained in:
Federico Hernandez 2010-07-28 18:07:09 +02:00
parent 96bd3ff8db
commit 903b5b34d4
5 changed files with 57 additions and 19 deletions

View file

@ -19,6 +19,7 @@
command. command.
+ Added feature #446, task supports now 'sow', 'som' and 'soy' as dates + Added feature #446, task supports now 'sow', 'som' and 'soy' as dates
for 'due', 'wait' and 'until' (thanks to T. Charles Yun). for 'due', 'wait' and 'until' (thanks to T. Charles Yun).
Added as well synonyms soww/eoww plus new socw/eocw for calendar weeks.
+ New 'depends' column for custom reports. + New 'depends' column for custom reports.
+ New 'blocked' report for showing blocked tasks. + New 'blocked' report for showing blocked tasks.
+ Improved man pages (thanks to Andy Lester). + Improved man pages (thanks to Andy Lester).

3
NEWS
View file

@ -20,6 +20,9 @@ New configuration options in task 1.9.3
- journal.time, journal.time.start.annotation, journal.time.stop.annotation - journal.time, journal.time.start.annotation, journal.time.stop.annotation
- 'sow', 'som' and 'soy' are now accepted in dates - 'sow', 'som' and 'soy' are now accepted in dates
'soww' and 'eoww' are now synonyms for 'sow' and 'eow' (ww = working week)
'socw' and 'eocw' refer to the calendar week (starting Sunday/Monday and
ending Saturday/Sunday)
Newly deprecated features in task 1.9.3 Newly deprecated features in task 1.9.3

View file

@ -387,21 +387,31 @@ task ... due:1day
task ... due:9hrs task ... due:9hrs
.TP .TP
End of week (Friday), month and year Start of (work) week (Monday), calendar week (Sunday or Monday), month and year
task ... due:eow
.br .br
task ... due:eom
.br
task ... due:eoy
.TP
Start of week (Sunday or Monday), month and year
task ... due:sow task ... due:sow
.br .br
task ... due:soww
.br
task ... due:socw
.br
task ... due:som task ... due:som
.br .br
task ... due:soy task ... due:soy
.TP
End of (work) week (Friday), calendar week (Saturday or Sunday), month and year
.br
task ... due:eow
.br
task ... due:eoww
.br
task ... due:eocw
.br
task ... due:eom
.br
task ... due:eoy
.TP .TP
Next occurring weekday Next occurring weekday
task ... due:fri task ... due:fri

View file

@ -885,9 +885,13 @@ bool Date::isRelativeDate (const std::string& input)
supported.push_back ("tomorrow"); supported.push_back ("tomorrow");
supported.push_back ("yesterday"); supported.push_back ("yesterday");
supported.push_back ("eow"); supported.push_back ("eow");
supported.push_back ("eoww");
supported.push_back ("eocw");
supported.push_back ("eom"); supported.push_back ("eom");
supported.push_back ("eoy"); supported.push_back ("eoy");
supported.push_back ("sow"); supported.push_back ("sow");
supported.push_back ("soww");
supported.push_back ("socw");
supported.push_back ("som"); supported.push_back ("som");
supported.push_back ("soy"); supported.push_back ("soy");
supported.push_back ("goodfriday"); supported.push_back ("goodfriday");
@ -907,14 +911,23 @@ bool Date::isRelativeDate (const std::string& input)
int dow; int dow;
if ((dow = Date::dayOfWeek (found)) != -1 || if ((dow = Date::dayOfWeek (found)) != -1 ||
found == "eow" || found == "eow" ||
found == "eoww" ||
found == "eocw" || found == "eocw" ||
found == "sow") found == "sow" ||
found == "soww" ||
found == "socw")
{ {
if (found == "eow") if (found == "eow" || found == "eoww")
dow = 5; dow = 5;
if (found == "sow") if (found == "eocw")
dow =Date::dayOfWeek (context.config.get ("weekstart")); dow = (Date::dayOfWeek (context.config.get ("weekstart")) + 6) % 7;
if (found == "sow" || found == "soww")
dow = 1;
if (found == "socw")
dow = Date::dayOfWeek (context.config.get ("weekstart"));
if (today.dayOfWeek () >= dow) if (today.dayOfWeek () >= dow)
today += (dow - today.dayOfWeek () + 7) * 86400; today += (dow - today.dayOfWeek () + 7) * 86400;
@ -968,15 +981,20 @@ bool Date::isRelativeDate (const std::string& input)
} }
else if (found == "som") else if (found == "som")
{ {
Date then (today.month (), int m = today.month () + 1;
1, int y = today.year ();
today.year ()); if (m > 12)
{
m -=12;
y++;
}
Date then (m, 1, y);
mT = then.mT; mT = then.mT;
return true; return true;
} }
else if (found == "soy") else if (found == "soy")
{ {
Date then (1, 1, today.year ()); Date then (1, 1, today.year () + 1);
mT = then.mT; mT = then.mT;
return true; return true;
} }

View file

@ -34,7 +34,7 @@ Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
UnitTest t (147); UnitTest t (149);
try try
{ {
@ -301,6 +301,9 @@ 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");
t.ok (r20 < now + (8 * 86400), "eocw < 7 days away");
Date r12 ("eom"); Date r12 ("eom");
t.ok (r12.sameMonth (now), "eom in same month as now"); t.ok (r12.sameMonth (now), "eom in same month as now");
@ -310,11 +313,14 @@ int main (int argc, char** argv)
Date r14 ("sow"); Date r14 ("sow");
t.ok (r14 < now + (8 * 86400), "sow < 7 days away"); t.ok (r14 < now + (8 * 86400), "sow < 7 days away");
Date r21 ("socw");
t.ok (r21 < now + (8 * 86400), "sow < 7 days away");
Date r15 ("som"); Date r15 ("som");
t.ok (r15.sameMonth (now), "eom in same month as now"); t.notok (r15.sameMonth (now), "som not in same month as now");
Date r16 ("soy"); Date r16 ("soy");
t.ok (r16.sameYear (now), "eoy in same year as now"); t.notok (r16.sameYear (now), "soy not in same year as now");
// Date::sameHour // Date::sameHour
Date r17 ("6/7/2010 01:00:00", "m/d/Y H:N:S"); Date r17 ("6/7/2010 01:00:00", "m/d/Y H:N:S");