about summary refs log tree commit homepage
path: root/lib/PublicInbox/Feed.pm
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2014-04-05 07:02:19 +0000
committerEric Wong <normalperson@yhbt.net>2014-04-05 07:10:35 +0000
commit8251e45156fd61e83d4249154627b87f5eafdf0a (patch)
tree52517d19bdebdd73b9bbb61fe2a42be15be073f9 /lib/PublicInbox/Feed.pm
parente97da7bb0d230fd624e7f21464c6355a4fdad119 (diff)
downloadpublic-inbox-8251e45156fd61e83d4249154627b87f5eafdf0a.tar.gz
This is a smaller module dependency-wise and should be easier-to-install
for folks with limited packaging systems or network/disk capacity.
We do not need very powerful date parsing, as bad date formats are
likely the work of spammers.
Diffstat (limited to 'lib/PublicInbox/Feed.pm')
-rw-r--r--lib/PublicInbox/Feed.pm7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 704effce..c97a3da8 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -12,8 +12,8 @@ use Encode::MIME::Header;
 use DateTime::Format::Mail;
 use CGI qw(escapeHTML);
 use POSIX qw(strftime);
+use Date::Parse qw(strptime);
 use constant DATEFMT => '%Y-%m-%dT%H:%M:%SZ';
-our $dt_parser = DateTime::Format::Mail->new(loose => 1);
 
 # main function
 # FIXME: takes too many args, cleanup
@@ -89,8 +89,9 @@ sub utf8_header {
 
 sub feed_date {
         my ($date) = @_;
-        my $dt = $dt_parser->parse_datetime($date);
-        $dt ? $dt->strftime(DATEFMT) : 0;
+        my @t = eval { strptime($date) };
+
+        scalar(@t) ? strftime(DATEFMT, @t) : 0;
 }
 
 # returns 0 (skipped) or 1 (added)