Improve date due filter

This commit is contained in:
Frederic Guillot 2015-06-28 18:57:25 -04:00
parent e22985df50
commit 7af5a923b0
2 changed files with 4 additions and 0 deletions

View File

@ -321,6 +321,8 @@ class TaskFilter extends Base
*/
public function filterByDueDate($date)
{
$this->query->neq('date_due', 0);
$this->query->notNull('date_due');
return $this->filterWithOperator('date_due', $date, true);
}

View File

@ -38,6 +38,8 @@ class TaskFilterTest extends Base
$this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is amazing', 'date_due' => $dp->getTimestampFromIsoFormat('+1 day'))));
$this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'Bob at work', 'date_due' => $dp->getTimestampFromIsoFormat('-1 day'))));
$this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'youpi', 'date_due' => $dp->getTimestampFromIsoFormat(time()))));
$this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'no due date')));
$this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'due date at 0', 'date_due' => 0)));
$tf->search('due:>'.date('Y-m-d'));
$tasks = $tf->findAll();