[OPEN-ILS-DEV] DateTime::Format::Duration
Bill Erickson
berickxx at gmail.com
Mon Jun 8 10:11:17 EDT 2015
>
>
> #This parses out the date fields from the timestamp string retrieved from
> database
>
> my ($year, $month, $day, $hour, $minute, $second, $tz) = $row[0] =~
> /^([0-9]{4})-([0-9]{2})-([0-9]{2})\s([0-9]{2}):([0-9]{2}):([0-9]{2})-([0-9]{2})\z/;
>
>
>
> my $last_date_entered = DateTime->new(
>
> year => $year,
>
> month => $month,
>
> day => $day,
>
> hour => $hour,
>
> minute => $minute,
>
> second => $second,
>
> time_zone => 'local',
>
> );
>
Hi Victoria, this is not exactly what you asked about, but I wanted to
point out that there are tools in Evergreen / OpenSRF to make date parsing
easier as well. Assuming $row[0] contains a date from the database (or
other ISO8601 date):
---
use DateTime::Format::ISO8601;
use OpenSRF::Utils qw/:datetime/;
my $last_date_entered =
DateTime::Format::ISO8601->parse_datetime(clense_ISO8601($row[0]));
> ---
Hope this is useful,
-b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libmail.georgialibraries.org/pipermail/open-ils-dev/attachments/20150608/7710d31f/attachment.html>
More information about the Open-ils-dev
mailing list