I\'d love to know if there is a module to parse \"human formatted\" dates in Perl. I mean things like \"tomorrow\", \"Tuesday\", \"next week\", \"1 hour ago\".
My re
you may also find it interesting to look at the DateTime::Format
family, specifically DateTime::Format::Natural. once you've parsed your date/time into a DateTime object, you can manipulate and evaluate it in a whole bunch of different ways.
here's a sample program:
use strict;
use warnings;
use DateTime::Format::Natural;
my( $parser ) = DateTime::Format::Natural->new;
while ( <> ) {
chomp;
my( $dt ) = $parser->parse_datetime( $_ );
if ( $parser->success ) {
print join( ' ', $dt->ymd, $dt->hms ) . "\n";
}
else {
print $parser->error . "\n";
}
}
output:
tomorrow
2008-11-18 21:48:49
next Tuesday
2008-11-25 21:48:53
1 week from now
2008-11-24 21:48:57
1 hour ago
2008-11-17 20:48:59
TMTOWTDI :)
-steve