[RFC] lib: add support for date:<query>..! to mean date:<query>..<query>

Tomi Ollila tomi.ollila at iki.fi
Sat Apr 18 01:07:10 PDT 2015


On Sat, Mar 07 2015, Jani Nikula <jani at nikula.org> wrote:

> Up to debate:
>
> 1) Is something like this useful at all as an intermediate step before
> we can have support for date:<query>? (This can be done with a future
> version of Xapian, or with a custom query query parser.)
>
> 2) If yes, are there better alternatives to "!" as the end point? (Or
> should the special case be the start point?) Also "@" and "same" have
> been suggested. Examples: date:yesterday..! date:today..@
> date:@..monday date:january..same.


I'd rather see a temporary ugly hack in implementation (to expand
date:<date> to date:<date>..<date>) than permanent interface feature.
But this looks simple enough... and I'd go just with this implementation
(i.e. <date>..!)


Tomi


> diff --git a/lib/parse-time-vrp.cc b/lib/parse-time-vrp.cc
> index 33f07db3410e..03804cf50fa8 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;
>  


More information about the notmuch mailing list