# (e.g. public-inbox-httpd@1 public-inbox-httpd@2) with the intention
# that they take turns running in-between upgrades. This should
# allow upgrading without downtime.
+# For servers expecting visitors from multiple timezones, TZ=UTC
+# is needed to ensure a consistent approxidate experience with search.
[Unit]
Description = public-inbox PSGI server %i
[Service]
Environment = PI_CONFIG=/home/pi/.public-inbox/config \
PATH=/usr/local/bin:/usr/bin:/bin \
+TZ=UTC \
PERL_INLINE_DIRECTORY=/tmp/.pub-inline
LimitNOFILE = 30000
push @$to_parse, $x;
$x = "\0%s$#$to_parse\0";
}
- $r[1] //= "\0%s+\0";
+ $r[1] //= "\0%s+\0"; # add 1 day
}
"$pfx:".join('..', @r).$end;
}
# git-rev-parse can handle any number of args up to system
# limits (around (4096*32) bytes on Linux).
my @r = $git->date_parse(@$to_parse);
- my $i;
- $_[2] =~ s/\0(%[%YmdHMSs]+)([0-9\+]+)\0/strftime($1,
- gmtime($2 eq '+' ? ($r[$i]+86400) : $r[$i=$2+0]))/sge;
+ # n.b. git respects TZ, times stored in SQLite/Xapian are always UTC,
+ # and gmtime doesn't seem to do the right thing when TZ!=UTC
+ my ($i, $t);
+ $_[2] =~ s/\0(%[%YmdHMSs]+)([0-9\+]+)\0/
+ $t = $2 eq '+' ? ($r[$i]+86400) : $r[$i=$2+0];
+ $1 eq '%s' ? $t : strftime($1, gmtime($t))/sge;
}
# n.b. argv never has NUL, though we'll need to filter it out
'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;