07 Aug 2012 19:05:24 UTC
- Distribution: Date-RangeParser-EN
- Module version: 0.03
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (2)
- Testers (3 / 6 / 0)
- KwaliteeBus factor: 0
- License: unknown
- Activity24 month
- Download (7.46KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionAQUILINA Michael Aquilina
Date::RangeParser::EN - Parser for plain English date/time range strings
use Date::RangeParser::EN; my $parser = Date::RangeParser::EN->new; my ($begin, $end) = $parser->parse_range("this week");
Parses plain-English strings representing date/time ranges
Returns a new instance of Date::RangeParser::EN.
Takes an optional hash of parameters:
By default, Date::RangeParser::EN returns two DateTime objects representing the beginning and end of the range. If you use a subclass of DateTime (or another module that implements the DateTime API), you may pass the name of this class to use it instead.
By default, Date::RangeParser::EN uses DateTime->now to determine the current date/time for calculations. If you need to work with a different time (for instance, if you need to adjust for time zones), you may pass a callback (code reference) which returns a DateTime object.
Accepts a string representing a plain-English date range, for instance:
the past 2 months
two weeks ago
the next 3 hours
the 3rd of next month
the end of this month
Returns two DateTime objects, reprensenting the beginning and end of the range.
There's a lot more that this module could handle. A few items that come to mind:
allow full words instead of digits ("two weeks ago" vs "2 weeks ago")
allow simple, easily-parsable ranges ("1/1/2012-12/31/2012")
allow larger ranges ("between last February and this Friday")
This module was authored by Grant Street Group (http://grantstreet.com), which was kind enough to give it back to the Perl community.
The CPAN distribution is maintained by Michael Aquilina (firstname.lastname@example.org).
Copyright (C) 2012 Grant Street Group.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Date::RangeParser::EN, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Date::RangeParser::EN
For more information on module installation, please visit the detailed CPAN module installation guide.