diff --git a/AUTHORS b/AUTHORS index 19b9b937b..06274dc7d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -125,4 +125,5 @@ suggestions: Joe Holloway Peter Lewis Najmi Ahmad Zabidi + Philipp Woelfel diff --git a/ChangeLog b/ChangeLog index 6b8a2d620..fe7cf2486 100644 --- a/ChangeLog +++ b/ChangeLog @@ -237,6 +237,8 @@ handling multiple arguments (thanks to Uli Martens). + Fixed bug #850, which failed when newline characters were in a modified task description. They are now stripped (thanks to Aikido Guy). + + Fixed bug #851, which failed to recognize durations like '1day' when + filtering date attributes (thanks to Philipp Woelfel). + Fixed bug #856, which prevented filters on missing project from working (thanks to Michelle Crane). + Fixed bug #859, which used only one color for the 'ghistory.*' report diff --git a/src/E9.cpp b/src/E9.cpp index 3a9e42dad..0f774b6b7 100644 --- a/src/E9.cpp +++ b/src/E9.cpp @@ -38,6 +38,7 @@ extern Context context; +//////////////////////////////////////////////////////////////////////////////// std::ostream& operator<< (std::ostream& out, const Arg& term) { out << term._value << "|" @@ -115,6 +116,7 @@ void E9::eval (const Task& task, std::vector & value_stack) } // TODO Not sure this is correct. + // TODO No longer sure why I was unsure in the first place. else if (arg->_raw == "-" && value_stack.size () < 2) { Arg right = value_stack.back (); @@ -173,10 +175,25 @@ void E9::eval (const Task& task, std::vector & value_stack) } else if (operand._type == Arg::type_date) { + // Could be a date, could be a duration, added to 'now'. operand._category = Arg::cat_literal; - operand._value = (operand._raw != "") - ? Date (operand._raw, _dateformat).toEpochString () - : ""; + if (operand._raw != "") + { + if (Date::valid (operand._raw, _dateformat)) + operand._value = Date (operand._raw, _dateformat).toEpochString (); + + else if (Duration::valid (operand._raw)) + { + Duration dur (operand._raw); + Date now; + now += (int)(time_t) dur; + operand._value = now.toEpochString (); + } + else + operand._value = ""; + } + else + operand._value = ""; } else if (operand._type == Arg::type_duration) { diff --git a/test/bug.851.t b/test/bug.851.t new file mode 100755 index 000000000..7bec6a37e --- /dev/null +++ b/test/bug.851.t @@ -0,0 +1,66 @@ +#! /usr/bin/perl +################################################################################ +## taskwarrior - a command line task list manager. +## +## Copyright 2006-2012, Paul Beckingham, Federico Hernandez. +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included +## in all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. +## +## http://www.opensource.org/licenses/mit-license.php +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 8; + +# Create the rc file. +if (open my $fh, '>', 'bug.rc') +{ + print $fh "data.location=.\n"; + close $fh; + ok (-r 'bug.rc', 'Created bug.rc'); +} + +# Bug 851: Filtering by due dates with ordinal and d/wks/etc. doesn't work +qx{../src/task rc:bug.rc add yesterday due:-2days}; +qx{../src/task rc:bug.rc add tomorrow due:2days}; +my $output = qx{../src/task rc:bug.rc ls}; +like ($output, qr/yesterday/, "yesterday - task added"); +like ($output, qr/tomorrow/, "tomorrow - task added"); + +$output = qx{../src/task rc:bug.rc list due.before:1d}; +like ($output, qr/yesterday/, "yesterday - found before:1d"); +unlike ($output, qr/tomorrow/, "tomorrow - not found before:1d"); + +$output = qx{../src/task rc:bug.rc list due.after:1d}; +unlike ($output, qr/yesterday/, "yesterday - not found after:1d"); +like ($output, qr/tomorrow/, "tomorrow - found after:1d"); + +# Cleanup. +unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc); +ok (! -r 'pending.data' && + ! -r 'completed.data' && + ! -r 'undo.data' && + ! -r 'backlog.data' && + ! -r 'synch.key' && + ! -r 'bug.rc', 'Cleanup'); + +exit 0; +