From 13efc7479362a18f582269dfbfe2d893ee9af579 Mon Sep 17 00:00:00 2001 From: djcb Date: Mon, 3 Jun 2013 22:29:50 +0300 Subject: [PATCH] * mu-query: better handle empty lhs/rhs in date intervals --- lib/mu-query.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/mu-query.cc b/lib/mu-query.cc index 5bdb1024..969d4be9 100644 --- a/lib/mu-query.cc +++ b/lib/mu-query.cc @@ -64,10 +64,16 @@ private: const char* str; time_t t; - str = mu_date_interpret_s (s.c_str(), is_begin ? TRUE: FALSE); - str = mu_date_complete_s (str, is_begin ? TRUE: FALSE); - t = mu_date_str_to_time_t (str, TRUE /*local*/); - str = mu_date_time_t_to_str_s (t, FALSE /*UTC*/); + // note: if s is empty and not is_begin, xapian seems + // to repeat it. + if (s.empty() || g_str_has_suffix (s.c_str(), "..")) { + str = mu_date_complete_s ("", is_begin); + } else { + str = mu_date_interpret_s (s.c_str(), is_begin ? TRUE: FALSE); + str = mu_date_complete_s (str, is_begin ? TRUE: FALSE); + t = mu_date_str_to_time_t (str, TRUE /*local*/); + str = mu_date_time_t_to_str_s (t, FALSE /*UTC*/); + } return s = std::string(str); }