mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-04 10:37:19 +02:00
Bug #851
- Fixed bug #851, which failed to recognize durations like '1day' when filtering date attributes (thanks to Philipp Woelfel). - Added unit tests.
This commit is contained in:
parent
9eee2e3e3e
commit
50825bc61a
4 changed files with 89 additions and 3 deletions
1
AUTHORS
1
AUTHORS
|
@ -125,4 +125,5 @@ suggestions:
|
||||||
Joe Holloway
|
Joe Holloway
|
||||||
Peter Lewis
|
Peter Lewis
|
||||||
Najmi Ahmad Zabidi
|
Najmi Ahmad Zabidi
|
||||||
|
Philipp Woelfel
|
||||||
|
|
||||||
|
|
|
@ -237,6 +237,8 @@
|
||||||
handling multiple arguments (thanks to Uli Martens).
|
handling multiple arguments (thanks to Uli Martens).
|
||||||
+ Fixed bug #850, which failed when newline characters were in a modified task
|
+ Fixed bug #850, which failed when newline characters were in a modified task
|
||||||
description. They are now stripped (thanks to Aikido Guy).
|
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
|
+ Fixed bug #856, which prevented filters on missing project from working
|
||||||
(thanks to Michelle Crane).
|
(thanks to Michelle Crane).
|
||||||
+ Fixed bug #859, which used only one color for the 'ghistory.*' report
|
+ Fixed bug #859, which used only one color for the 'ghistory.*' report
|
||||||
|
|
23
src/E9.cpp
23
src/E9.cpp
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::ostream& operator<< (std::ostream& out, const Arg& term)
|
std::ostream& operator<< (std::ostream& out, const Arg& term)
|
||||||
{
|
{
|
||||||
out << term._value << "|"
|
out << term._value << "|"
|
||||||
|
@ -115,6 +116,7 @@ void E9::eval (const Task& task, std::vector <Arg>& value_stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Not sure this is correct.
|
// 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)
|
else if (arg->_raw == "-" && value_stack.size () < 2)
|
||||||
{
|
{
|
||||||
Arg right = value_stack.back ();
|
Arg right = value_stack.back ();
|
||||||
|
@ -173,10 +175,25 @@ void E9::eval (const Task& task, std::vector <Arg>& value_stack)
|
||||||
}
|
}
|
||||||
else if (operand._type == Arg::type_date)
|
else if (operand._type == Arg::type_date)
|
||||||
{
|
{
|
||||||
|
// Could be a date, could be a duration, added to 'now'.
|
||||||
operand._category = Arg::cat_literal;
|
operand._category = Arg::cat_literal;
|
||||||
operand._value = (operand._raw != "")
|
if (operand._raw != "")
|
||||||
? Date (operand._raw, _dateformat).toEpochString ()
|
{
|
||||||
: "";
|
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)
|
else if (operand._type == Arg::type_duration)
|
||||||
{
|
{
|
||||||
|
|
66
test/bug.851.t
Executable file
66
test/bug.851.t
Executable file
|
@ -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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue