Monica L wrote:
Hi All,
I'm fairly new to Perl, and I'm working on a program
that needs to convert a date/time from the RFC 822
format (ie, Sat, 07 Sep 2002 00:00:01 GMT) to the ISO
8601 format. Does anyone know if there are any Perl
modules that will do this conversion? I heard of the
Date::Manip module, but I'm not sure if this is the
right module to use or if there are other ones?
Also, is there a module that will test if a date is
already in ISO 8601 format so that I can skip the
conversion?
if ($date !~ /\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}/) {
$date = DateTime::Format::W3CDTF->parse_datetime( $date )->datetime;
}
This assumes that $date is either in ISO format or W3C format .. If you
don't know what your date format is ahead of time though, that
assumption may be invalid.
Cheers!
Rick Measham