]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwAtomStream.pm
update copyrights for 2018
[public-inbox.git] / lib / PublicInbox / WwwAtomStream.pm
index a6817b31475c4e2df23c9d2ab141d56f64a09b1f..b69de856500f6a67fe7168968ea2e36fc9473617 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Atom body stream for which yields getline+close methods
@@ -6,9 +6,8 @@ package PublicInbox::WwwAtomStream;
 use strict;
 use warnings;
 
-# FIXME: locale-independence:
 use POSIX qw(strftime);
-use Date::Parse qw(strptime);
+use Date::Parse qw(str2time);
 use Digest::SHA qw(sha1_hex);
 use PublicInbox::Address;
 use PublicInbox::Hval qw(ascii_html);
@@ -110,8 +109,8 @@ sub feed_entry {
        }
        my $href = $base . mid_escape($mid) . '/';
        my $date = $hdr->header('Date');
-       my @t = eval { strptime($date) } if defined $date;
-       @t = gmtime(time) unless scalar @t;
+       my $t = eval { str2time($date) } if defined $date;
+       my @t = gmtime(defined $t ? $t : time);
        my $updated = feed_updated(@t);
 
        my $title = $hdr->header('Subject');
@@ -130,13 +129,13 @@ sub feed_entry {
        }
        $s .= "<entry><author><name>$name</name><email>$email</email>" .
                "</author>$title$updated" .
+               qq(<link\nhref="$href"/>).
+               "<id>$uuid</id>$irt" .
                qq{<content\ntype="xhtml">} .
                qq{<div\nxmlns="http://www.w3.org/1999/xhtml">} .
                qq(<pre\nstyle="white-space:pre-wrap">) .
                PublicInbox::View::multipart_text_as_html($mime, $href) .
-               '</pre>' .
-               qq!</div></content><link\nhref="$href"/>!.
-               "<id>$uuid</id>$irt</entry>";
+               '</pre></div></content></entry>';
 }
 
 sub feed_updated {