user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: meta@public-inbox.org
Subject: [PATCH] wwwatomstream: call gmtime with scalar
Date: Fri, 22 Oct 2021 00:49:35 -0400	[thread overview]
Message-ID: <20211022044935.135785-1-kyle@kyleam.com> (raw)

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 | 3 ++-
 t/psgi_v2.t                      | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm
index f60251b7..5d32294e 100644
--- a/lib/PublicInbox/WwwAtomStream.pm
+++ b/lib/PublicInbox/WwwAtomStream.pm
@@ -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;
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index e0570682..64c1a8d3 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -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 };

base-commit: 4cd7a78f3b8c03670e2d77675229472506eee1eb
-- 
2.33.1


             reply	other threads:[~2021-10-22  4:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22  4:49 Kyle Meyer [this message]
2021-10-22  5:31 ` [PATCH] wwwatomstream: call gmtime with scalar Eric Wong

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=20211022044935.135785-1-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).