From d0db821298278dd7cdbf2b472d672d69a0f0a95e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 30 Jul 2010 22:46:07 -0400 Subject: [PATCH] Bug 452 - Need relative date value 'now' to fully support times - Added 'now' as a relative date. - Modified 'overdue' report to use 'now' instead of 'today' as the distinction between due and overdue. --- ChangeLog | 10 ++++++---- NEWS | 3 +++ src/Config.cpp | 2 +- src/Date.cpp | 7 +++++++ src/tests/date.t.cpp | 9 ++++++++- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4675334b..756c1a99b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,14 +37,16 @@ + Fixed bug #439, which ignored dateformat.annotation for sparse annotations. + Fixed bug #441, which misparsed '/a/a:/' as an attribute, rather than a substitution (thanks to Michelle Crane). - + Fixed bug #445, which caused task to not notice that the command 'h' is - ambiguous. - + Fixed problem with command line configuration overrides that had no - values. + Fixed bug #444, which made task shell unusable after canceling out of an undo command. + + Fixed bug #445, which caused task to not notice that the command 'h' is + ambiguous. + Fixed bug #449, so the wait: attribute can be applied to a task at any time, not just on add. + + Fixed bug #452, which defines a higher resolution division between due + and overdue. + + Fixed problem with command line configuration overrides that had no + values. ------ old releases ------------------------------ diff --git a/NEWS b/NEWS index ee39b3743..07f7fec4c 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,9 @@ New Features in task 1.9.3 $ task ... due:4d $ task ... due:3wks - Now supports the beginning of the week, month and year in dates. + - Now supports 'now' as a date. + - Now defines an overdue task as being one second after the due date, + instead of the day after the due date. Please refer to the ChangeLog file for full details. There are too many to list here. diff --git a/src/Config.cpp b/src/Config.cpp index a42ddaebc..3cbeb1a80 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -303,7 +303,7 @@ std::string Config::defaults = "report.overdue.columns=id,project,priority,due,active,age,description\n" "report.overdue.labels=ID,Project,Pri,Due,Active,Age,Description\n" "report.overdue.sort=due+,priority-,active-,project+\n" - "report.overdue.filter=status:pending due.before:today\n" + "report.overdue.filter=status:pending due.before:now\n" "#report.overdue.dateformat=m/d/Y\n" "#report.overdue.annotations=full\n" "\n" diff --git a/src/Date.cpp b/src/Date.cpp index 64d7f58c3..cc0ac67ba 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -868,6 +868,7 @@ bool Date::isEpoch (const std::string& input) // eow (end of week) // eom (end of month) // eoy (end of year) +// now bool Date::isRelativeDate (const std::string& input) { std::string in (lowerCase (input)); @@ -901,6 +902,7 @@ bool Date::isRelativeDate (const std::string& input) supported.push_back ("pentecost"); supported.push_back ("midsommar"); supported.push_back ("midsommarafton"); + supported.push_back ("now"); std::vector matches; if (autoComplete (in, supported, matches) == 1) @@ -1052,6 +1054,11 @@ bool Date::isRelativeDate (const std::string& input) } } } + else if (found == "now") + { + mT = time (NULL); + return true; + } } // Support "21st" to indicate the next date that is the 21st day. diff --git a/src/tests/date.t.cpp b/src/tests/date.t.cpp index 8d3b663c0..b013ff300 100644 --- a/src/tests/date.t.cpp +++ b/src/tests/date.t.cpp @@ -34,7 +34,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (150); + UnitTest t (154); try { @@ -49,6 +49,13 @@ int main (int argc, char** argv) t.ok (now >= yesterday, "now >= yesterday"); t.ok (now > yesterday, "now > yesterday"); + // Date::Date ("now") + Date relative_now ("now"); + t.ok (relative_now.sameHour (now), "Date ().sameHour (Date (now))"); + t.ok (relative_now.sameDay (now), "Date ().sameDay (Date (now))"); + t.ok (relative_now.sameMonth (now), "Date ().sameMonth (Date (now))"); + t.ok (relative_now.sameYear (now), "Date ().sameYear (Date (now))"); + // Loose comparisons. Date left ("7/4/2008"); Date comp1 ("7/4/2008");