DateTime::Format::Natural - Create machine readable date/time with natural parsing logic
use DateTime::Format::Natural; $parser = DateTime::Format::Natural->new; $dt = $parser->parse_datetime($date_string);
DateTime::Format::Natural takes a string with a human readable date/time and creates a machine readable one by applying natural parsing logic.
DateTime::Format::Natural
Creates a new DateTime::Format::Natural object. Arguments to new() are options and not necessarily required.
new()
$parser = DateTime::Format::Natural->new( lang => '[en|de]', format => 'mm/dd/yy', daytime => { morning => 06, afternoon => 13, evening => 20, }, );
Contains the language selected, currently limited to en (english) & de (german). Defaults to 'en'.
en
de
Specifies the format of numeric dates, defaults to 'd/m/y'.
d/m/y
A hash consisting of specific hours given for peculiar daytimes. Daytimes may be selectively changed.
Creates a DateTime object from a human readable date/time string.
DateTime
$dt = $parser->parse_datetime($date_string); $dt = $parser->parse_datetime( string => $date_string, debug => 1, );
The date string.
Boolean value indicating debugging mode.
If debugging is enabled, each token that is analysed will be output to STDOUT with a trailing newline appended.
Returns a DateTime object.
See the modules DateTime::Format::Natural::Lang::* for a overview of valid input.
DateTime::Format::Natural::Lang::*
Thanks to Tatsuhiko Miyagawa for the initial inspiration. See Miyagawa's journal entry http://use.perl.org/~miyagawa/journal/31378 for more information.
Furthermore, thanks to (in order of appearance) who have contributed valuable suggestions & patches:
Clayton L. Scott Dave Rolsky CPAN Author 'SEKIMURA' mike (pulsation) Mark Stosberg Tuomas Jormola
DateTime, Date::Calc, http://datetime.perl.org
Steven Schubiger <schubiger@cpan.org>
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install DateTime::Format::Natural, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DateTime::Format::Natural
CPAN shell
perl -MCPAN -e shell install DateTime::Format::Natural
For more information on module installation, please visit the detailed CPAN module installation guide.