This will do what you're after in your example.
use Date::Manip; my $str_date = shift || die "No date!\n"; # almost *any* format my $date = UnixDate( ParseDate( $str_date ), "%b %e, %Y %r"); $date || die "Could not interpret date: $str_date!\n"; print $date, "\n";
You could also try to write up a regex/sub to check based on what the RSSes are supposed to follow, RFC #822, but I'm sure there are RSSes that break it.
One could argue that using Date::Manip to allow arbitrary dates (eg, it will even work on things like "10 days ago at noon UT") is really a bad idea b/c it allows RSS writers to get away with breaking the specification. And Date::Manip is slow but unless it's being run off a highly trafficked CGI it probably doesn't matter.
In reply to Re: Parsing RSS dates
by Your Mother
in thread Parsing RSS dates
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |