Use another formatter, simply
version 0.81
use DateTime::Format::Builder ( parsers => { parse_datetime => [ { Quick => 'DateTime::Format::HTTP' }, { Quick => 'DateTime::Format::Mail' }, { Quick => 'DateTime::Format::IBeat' }, ]});
is the same as:
use DateTime::Format::HTTP; use DateTime::Format::Mail; use DateTime::Format::IBeat;
use DateTime::Format::Builder ( parsers => { parse_datetime => [ sub { eval { DateTime::Format::HTTP->parse_datetime( $_[1] ) } }, sub { eval { DateTime::Format::Mail->parse_datetime( $_[1] ) } }, sub { eval { DateTime::Format::IBeat->parse_datetime( $_[1] ) } }, ]});
(These two pieces of code can both be found in the test suite; one as quick.t, the other as fall.t.)
\*(C`Quick\*(C' adds a parser that allows some shortcuts when writing fairly standard and mundane calls to other formatting modules.
\*(C`Quick\*(C' has two keys, one optional.
The \*(C`Quick\*(C' keyword should have an argument of either an object or a class name. If it's a class name then the class is \*(C`use\*(C'd.
The \*(C`method\*(C' keyword is optional with a default of \*(C`parse_datetime\*(C'. It's either name of the method to invoke on the object, or a reference to a piece of code.
In any case, the resultant code ends up looking like:
my $rv = $Quick->$method( $date );
See DateTime::Format::Builder for details.
\*(C`[email protected]\*(C' mailing list.
http://datetime.perl.org/
perl, DateTime, DateTime::Format::Builder
Dave Rolsky <[email protected]>
Iain Truskett
This software is Copyright (c) 2013 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)