From e9a71b7db926c614c4e27d8f67744a186bcd5404 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 12 Sep 2008 15:25:38 -0400 Subject: [PATCH] - Fixed bug where relative dates in filters (task list due:eom, task list due:tomorrow, task list due:23rd ...) are now properly supported. --- ChangeLog | 2 ++ html/task.html | 3 +++ src/Date.cpp | 21 +++++++++++++++++---- src/report.cpp | 2 ++ src/tests/in | 15 +++++++++++++++ src/tests/out | 15 +++++++++++++++ 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100755 src/tests/in create mode 100755 src/tests/out diff --git a/ChangeLog b/ChangeLog index 566dde826..2b73ee2a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,8 @@ represents a feature release, and the Z represents a patch. the new "default.project" and "default.priority" configuration variables (thanks to Vincent Fleuranceau) + Task supports improved word-wrapping to the terminal width + + Bug: Now properly supports relative dates in filters (task list due:eom, + task list due:tomorrow, task list due:23rd ...) ------ old releases ------------------------------ diff --git a/html/task.html b/html/task.html index c1c3e76f6..feca286da 100644 --- a/html/task.html +++ b/html/task.html @@ -104,6 +104,9 @@ the new "default.project" and "default.priority" configuration variables (thanks to Vincent Fleuranceau).
  • Task supports improved word-wrapping to the terminal width. +
  • Fixed bug so that relative dates in filters (task list due:eom, + task list due:tomorrow, task list due:23rd ...) are now properly + supported.

    diff --git a/src/Date.cpp b/src/Date.cpp index f7378bbb3..67ac7e7c7 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -543,22 +543,35 @@ bool Date::isRelativeDate (const std::string& input) else today += (dow - today.dayOfWeek ()) * 86400; - mT = today.mT; + int m, d, y; + today.toMDY (m, d, y); + Date then (m, d, y); + + mT = then.mT; return true; } else if (found == "today") { - mT = today.mT; + Date then (today.month (), + today.day (), + today.year ()); + mT = then.mT; return true; } else if (found == "tomorrow") { - mT = today.mT + 86400; + Date then (today.month (), + today.day (), + today.year ()); + mT = then.mT + 86400; return true; } else if (found == "yesterday") { - mT = today.mT - 86400; + Date then (today.month (), + today.day (), + today.year ()); + mT = then.mT - 86400; return true; } else if (found == "eom") diff --git a/src/report.cpp b/src/report.cpp index c3c928b28..c82abeaac 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -79,6 +79,7 @@ void filter (std::vector& all, T& task) // Apply attribute filter. matches = 0; foreach (a, attrList) + { if (a->first == "project") { if (a->second.length () <= refTask.getAttribute (a->first).length ()) @@ -87,6 +88,7 @@ void filter (std::vector& all, T& task) } else if (a->second == refTask.getAttribute (a->first)) ++matches; + } if (matches == attrList.size ()) { diff --git a/src/tests/in b/src/tests/in new file mode 100755 index 000000000..761c1f877 --- /dev/null +++ b/src/tests/in @@ -0,0 +1,15 @@ +./task add monday due:monday +./task add tuesday due:tuesday +./task add wednesday due:wednesday +./task add thursday due:thursday +./task add friday due:friday +./task add saturday due:saturday +./task add sunday due:sunday +./task add yesterday due:yesterday +./task add today due:today +./task add tomorrow due:tomorrow +./task add eow due:eow +./task add eom due:eom +./task add eoy due:eoy +./task add 21st due:21st + diff --git a/src/tests/out b/src/tests/out new file mode 100755 index 000000000..c0b81f3b4 --- /dev/null +++ b/src/tests/out @@ -0,0 +1,15 @@ +./task li due:monday +./task li due:tuesday +./task li due:wednesday +./task li due:thursday +./task li due:friday +./task li due:saturday +./task li due:sunday +./task li due:yesterday +./task li due:today +./task li due:tomorrow +./task li due:eow +./task li due:eom +./task li due:eoy +./task li due:21st +