From 74a84a28e34f3c1c38631fb80cc74ab589a44298 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 25 May 2016 21:00:01 -0400 Subject: Support strtotime strings for date search --- app/Core/Filter/Lexer.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/Core/Filter/Lexer.php b/app/Core/Filter/Lexer.php index 041b58d3..8a7a68b1 100644 --- a/app/Core/Filter/Lexer.php +++ b/app/Core/Filter/Lexer.php @@ -26,9 +26,10 @@ class Lexer */ private $tokenMap = array( "/^(\s+)/" => 'T_WHITESPACE', - '/^([<=>]{0,2}[0-9]{4}-[0-9]{2}-[0-9]{2})/' => 'T_DATE', - '/^(yesterday|tomorrow|today)/' => 'T_DATE', - '/^("(.*?)")/' => 'T_STRING', + '/^([<=>]{0,2}[0-9]{4}-[0-9]{2}-[0-9]{2})/' => 'T_STRING', + '/^([<=>]{1,2}\w+)/' => 'T_STRING', + '/^([<=>]{1,2}".+")/' => 'T_STRING', + '/^("(.+)")/' => 'T_STRING', "/^(\w+)/" => 'T_STRING', "/^(#\d+)/" => 'T_STRING', ); @@ -107,7 +108,7 @@ class Lexer $this->offset += strlen($matches[1]); return array( - 'match' => trim($matches[1], '"'), + 'match' => str_replace('"', '', $matches[1]), 'token' => $name, ); } @@ -134,7 +135,7 @@ class Lexer } else { $next = next($tokens); - if ($next !== false && in_array($next['token'], array('T_STRING', 'T_DATE'))) { + if ($next !== false && $next['token'] === 'T_STRING') { $map[$token['token']][] = $next['match']; } } -- cgit v1.2.3