aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJani Nikula <jani@nikula.org>2015-08-15 14:25:47 +0300
committerDavid Bremner <david@tethera.net>2015-09-25 21:55:24 -0300
commit23b8ed610a13802f0afa5fa70bc8faa04cf48a7f (patch)
tree914775d285aa874cad69ede04c906cb9436f980c /lib
parent3cf7ed26c06fb3fa7145948fd9a9f2973037a5fd (diff)
lib: add support for date:<expr>..! to mean date:<expr>..<expr>
It doesn't seem likely we can support simple date:<expr> expanding to date:<expr>..<expr> any time soon. (This can be done with a future version of Xapian, or with a custom query query parser.) In the mean time, provide shorthand date:<expr>..! to mean the same. This is useful, as the expansion takes place before interpetation, and we can use, for example, date:yesterday..! to match from beginning of yesterday to end of yesterday. Idea from Mark Walters <markwalters1009@gmail.com>.
Diffstat (limited to 'lib')
-rw-r--r--lib/parse-time-vrp.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/parse-time-vrp.cc b/lib/parse-time-vrp.cc
index 33f07db3..03804cf5 100644
--- a/lib/parse-time-vrp.cc
+++ b/lib/parse-time-vrp.cc
@@ -31,6 +31,7 @@ Xapian::valueno
ParseTimeValueRangeProcessor::operator() (std::string &begin, std::string &end)
{
time_t t, now;
+ std::string b;
/* Require date: prefix in start of the range... */
if (STRNCMP_LITERAL (begin.c_str (), PREFIX))
@@ -38,6 +39,7 @@ ParseTimeValueRangeProcessor::operator() (std::string &begin, std::string &end)
/* ...and remove it. */
begin.erase (0, sizeof (PREFIX) - 1);
+ b = begin;
/* Use the same 'now' for begin and end. */
if (time (&now) == (time_t) -1)
@@ -51,6 +53,9 @@ ParseTimeValueRangeProcessor::operator() (std::string &begin, std::string &end)
}
if (!end.empty ()) {
+ if (end == "!" && ! b.empty ())
+ end = b;
+
if (parse_time_string (end.c_str (), &t, &now, PARSE_TIME_ROUND_UP_INCLUSIVE))
return Xapian::BAD_VALUENO;