DateTime::Format::Flexible - DateTime::Format::Flexible - Flexibly parse strings and turn them into DateTime objects.
use DateTime::Format::Flexible; my $dt = DateTime::Format::Flexible->build( 'January 8, 1999' ); # $dt = a DateTime object set at 1999-01-08T00:00:00
If you have ever had to use a program that made you type in the date a certain way and thought "Why can't the computer just figure out what date I wanted?", this module is for you.
It attempts to take any string you give it and parse it into a DateTime object.
For supported string formats, see the test file. If you can think of any that I do not cover, please let me know.
This module uses DateTime::Format::Builder under the covers. It only has one method (build).
my $dt = DateTime::Format::Flexible->build( $date );
A small list of supported formats:
there are 2800+ variations that are detected correctly in the test file.
You cannot use a 1 or 2 digit year as the first field:
YY-MM-DD # not supported Y-MM-DD # not supported
It would get confused with MM-DD-YY
It also prefers the US format of MM-DD over the European DD-MM.
Tom Heady
CPAN ID: thinc
Punch, Inc.
cpan@punch.net
http://www.punch.net/
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
perl(1). DateTime::Format::Builder