diff options
author | Eric Wong <normalperson@yhbt.net> | 2014-04-05 07:02:19 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2014-04-05 07:10:35 +0000 |
commit | 8251e45156fd61e83d4249154627b87f5eafdf0a (patch) | |
tree | 52517d19bdebdd73b9bbb61fe2a42be15be073f9 /lib | |
parent | e97da7bb0d230fd624e7f21464c6355a4fdad119 (diff) | |
download | public-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')
-rw-r--r-- | lib/PublicInbox/Feed.pm | 7 |
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) |