unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [SQUASH] fix "d:YYYYMMDD..$NEEDS_APPROXIDATE" case
Date: Sat, 17 Apr 2021 00:00:22 +0000	[thread overview]
Message-ID: <20210417000022.GA29300@dcvr> (raw)
In-Reply-To: <20210416234306.28897-1-e@80x24.org>

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index e0e8164d..fbcff2c3 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -302,7 +302,10 @@ sub date_parse_prepare {
 				$x = "$fmt$#$to_parse\0";
 			}
 			if ($pfx eq 'dt') {
-				s/\0%Y%m%d/\0%Y%m%d%H%M%S/ for @r;
+				for (@r) {
+					s/\0%Y%m%d/\0%Y%m%d%H%M%S/;
+					s/\A([0-9]{8})\z/${1}000000/;
+				}
 			}
 		}
 	} elsif ($pfx eq 'dt') {
diff --git a/t/search.t b/t/search.t
index b63a7672..47a67f7f 100644
--- a/t/search.t
+++ b/t/search.t
@@ -630,6 +630,11 @@ SKIP: {
 	like($qs, qr/\Abroken dt:$x_days_ago[0-9]{6}\.\./,
 		'date.phrase.with.dots');
 
+	$orig = $qs = 'd:20101002..now';
+	$s->query_approxidate($g, $qs);
+	like($qs, qr/\Adt:20101002000000\.\.[0-9]{14}\z/,
+		'approxidate on range-end only');
+
 	$ENV{TEST_EXPENSIVE} or
 		skip 'TEST_EXPENSIVE not set for argv overflow check', 1;
 	my @w;

      reply	other threads:[~2021-04-17  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 23:43 [PATCH] search: expand "d:" to "dt:" for precision with approxidate Eric Wong
2021-04-17  0:00 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210417000022.GA29300@dcvr \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).