From fe1b11bf5a752743167018f77e2826304ba0aa0e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 17 Sep 2021 13:40:07 +0900 Subject: search: fix rt: w/ approxidate when TZ != UTC While git respects a user's local timezone and returns seconds-since-the-Epoch, we were unnecessarily and incorrectly calling gmtime+strftime on its result. So ignore calling gmtime+strftime when the strftime format is "%s", just feed the output time from git directly to Xapian. This is mainly for lei, which will likely run in a variety of timezones. While we're at it, add a recommendation to use TZ=UTC in public-inbox-httpd, in case there are (misguided :P) sysadmins who set a non-UTC TZ. --- t/lei_store.t | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 't') diff --git a/t/lei_store.t b/t/lei_store.t index 73b5c74d..c31e27a2 100644 --- a/t/lei_store.t +++ b/t/lei_store.t @@ -124,4 +124,28 @@ SKIP: { 'kw_changed undef on unknown message'); } +SKIP: { + require_mods(qw(HTTP::Date), 1); + my $now = HTTP::Date::time2str(time); + $now =~ s/GMT/+0000/ or xbail "no GMT in $now"; + my $eml = PublicInbox::Eml->new(<<"EOM"); +Received: (listserv\@example.com) by example.com via listexpand + id abcde (ORCPT ); + $now; +Date: $now +Subject: timezone-dependent test + +WHAT IS TIME ANYMORE? +EOM + + ok($sto->add_eml($eml), 'recently received message'); + $sto->done; + local $ENV{TZ} = 'GMT+5'; + my $lse = $sto->search; + my $qstr = 'rt:1.hour.ago.. s:timezone'; + $lse->query_approxidate($lse->git, $qstr); + my $mset = $lse->mset($qstr); + is($mset->size, 1, 'rt:1.hour.ago.. works w/ local time'); +} + done_testing; -- cgit v1.2.3-24-ge0c7