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

- Added sow (depending on rc.weekstart), som and soy as possible
  dates (similar to eow, eom and eoy).
This commit is contained in:
Federico Hernandez 2010-07-28 00:15:26 +02:00
parent a6fbb40a12
commit 96bd3ff8db
5 changed files with 51 additions and 8 deletions

View file

@ -17,6 +17,8 @@
tasks, provide a new sort order and include the 'end' column. tasks, provide a new sort order and include the 'end' column.
+ Added feature #431, which improves feedback after running the 'log' + Added feature #431, which improves feedback after running the 'log'
command. command.
+ Added feature #446, task supports now 'sow', 'som' and 'soy' as dates
for 'due', 'wait' and 'until' (thanks to T. Charles Yun).
+ 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).

2
NEWS
View file

@ -6,6 +6,7 @@ New Features in task 1.9.3
- Now supports durations in dates, such as: - Now supports durations in dates, such as:
$ task ... due:4d $ task ... due:4d
$ task ... due:3wks $ task ... due:3wks
- Now supports the beginning of the week, month and year in dates.
Please refer to the ChangeLog file for full details. There are too many to Please refer to the ChangeLog file for full details. There are too many to
list here. list here.
@ -18,6 +19,7 @@ New commands in task 1.9.3
New configuration options in task 1.9.3 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
Newly deprecated features in task 1.9.3 Newly deprecated features in task 1.9.3

View file

@ -394,6 +394,14 @@ task ... due:eom
.br .br
task ... due:eoy task ... due:eoy
.TP
Start of week (Sunday or Monday), month and year
task ... due:sow
.br
task ... due:som
.br
task ... due:soy
.TP .TP
Next occurring weekday Next occurring weekday
task ... due:fri task ... due:fri

View file

@ -887,6 +887,9 @@ bool Date::isRelativeDate (const std::string& input)
supported.push_back ("eow"); supported.push_back ("eow");
supported.push_back ("eom"); supported.push_back ("eom");
supported.push_back ("eoy"); supported.push_back ("eoy");
supported.push_back ("sow");
supported.push_back ("som");
supported.push_back ("soy");
supported.push_back ("goodfriday"); supported.push_back ("goodfriday");
supported.push_back ("easter"); supported.push_back ("easter");
supported.push_back ("eastermonday"); supported.push_back ("eastermonday");
@ -903,11 +906,16 @@ bool Date::isRelativeDate (const std::string& input)
// If day name. // If day name.
int dow; int dow;
if ((dow = Date::dayOfWeek (found)) != -1 || if ((dow = Date::dayOfWeek (found)) != -1 ||
found == "eow") found == "eow" ||
found == "eocw" ||
found == "sow")
{ {
if (found == "eow") if (found == "eow")
dow = 5; dow = 5;
if (found == "sow")
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;
else else
@ -958,6 +966,20 @@ bool Date::isRelativeDate (const std::string& input)
mT = then.mT; mT = then.mT;
return true; return true;
} }
else if (found == "som")
{
Date then (today.month (),
1,
today.year ());
mT = then.mT;
return true;
}
else if (found == "soy")
{
Date then (1, 1, today.year ());
mT = then.mT;
return true;
}
else if (found == "goodfriday") else if (found == "goodfriday")
{ {
Date then (Date::easter(today.year())); Date then (Date::easter(today.year()));

View file

@ -34,7 +34,7 @@ Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
UnitTest t (144); UnitTest t (147);
try try
{ {
@ -307,13 +307,22 @@ int main (int argc, char** argv)
Date r13 ("eoy"); Date r13 ("eoy");
t.ok (r13.sameYear (now), "eoy in same year as now"); t.ok (r13.sameYear (now), "eoy in same year as now");
// Date::sameHour Date r14 ("sow");
Date r14 ("6/7/2010 01:00:00", "m/d/Y H:N:S"); t.ok (r14 < now + (8 * 86400), "sow < 7 days away");
Date r15 ("6/7/2010 01:59:59", "m/d/Y H:N:S");
t.ok (r14.sameHour (r15), "two dates within the same hour");
Date r16 ("6/7/2010 00:59:59", "m/d/Y H:N:S"); Date r15 ("som");
t.notok (r14.sameHour (r16), "two dates not within the same hour"); t.ok (r15.sameMonth (now), "eom in same month as now");
Date r16 ("soy");
t.ok (r16.sameYear (now), "eoy 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 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");
// TODO Date::operator- // TODO Date::operator-
} }