]> Sergey Matveev's repositories - public-inbox.git/commitdiff
wwwatomstream: call gmtime with scalar
authorKyle Meyer <kyle@kyleam.com>
Fri, 22 Oct 2021 04:49:35 +0000 (00:49 -0400)
committerEric Wong <e@80x24.org>
Fri, 22 Oct 2021 05:28:14 +0000 (05:28 +0000)
When the gmtime() calls were moved from feed_entry() and atom_header()
into feed_updated() in c447bbbd, @_ rather than a scalar was passed to
gmtime().  As a result, feed <updated> values end up as
"1970-01-01T00:00:00Z".

Switch back to using a scalar argument to restore the correct
timestamps.

Fixes: c447bbbddb4ac8e1 ("wwwatomstream: simplify feed_update callers")
lib/PublicInbox/WwwAtomStream.pm
t/psgi_v2.t

index f60251b7ef12c2779779e4e81bf9186689acca2e..5d32294eec159f58cb9b2ff7153f512c5d0d3b63 100644 (file)
@@ -161,7 +161,8 @@ sub feed_entry {
 }
 
 sub feed_updated {
-       '<updated>' . strftime('%Y-%m-%dT%H:%M:%SZ', gmtime(@_)) . '</updated>';
+       my ($t) = @_;
+       '<updated>' . strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($t)) . '</updated>';
 }
 
 1;
index e057068226ac0eac778ec6cb82cea85ec38c8656..64c1a8d38a0a5b842568657bde03d71175ec17a3 100644 (file)
@@ -92,6 +92,11 @@ my $client0 = sub {
        @bodies = ($res->content =~ /^(hello [^<]+)$/mg);
        is_deeply(\@bodies, [ "hello world!\n", "hello world\n" ],
                'new.html ordering is chronological');
+
+       $res = $cb->(GET('/v2test/new.atom'));
+       my @dates = ($res->content =~ m!title><updated>([^<]+)</updated>!g);
+       is_deeply(\@dates, [ "1993-10-02T00:01:00Z", "1993-10-02T00:00:00Z" ],
+               'Date headers made it through');
 };
 test_psgi(sub { $www->call(@_) }, $client0);
 my $env = { TMPDIR => $tmpdir, PI_CONFIG => $cfgpath };