about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-17 13:40:07 +0900
committerEric Wong <e@80x24.org>2021-09-17 04:41:11 +0000
commitfe1b11bf5a752743167018f77e2826304ba0aa0e (patch)
tree955d2dad4b8ed11794f276f3c7ce5fcebadc8884 /t
parent23ac27869da4744aba2a67454504b7a157583df7 (diff)
downloadpublic-inbox-fe1b11bf5a752743167018f77e2826304ba0aa0e.tar.gz
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.
Diffstat (limited to 't')
-rw-r--r--t/lei_store.t24
1 files changed, 24 insertions, 0 deletions
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 <rfc822;u\@example.com>);
+        $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;