Subject: | [DateTime::Format::Pg] uninitialized year in _fix_timezone on parse_datetime('14:00:00') |
Date: | Sun, 18 Jan 2009 19:30:46 +0100 |
To: | bug-DateTime-Format-Pg [...] rt.cpan.org |
From: | Gerhard Heift <cpan-20090118-7280 [...] gheift.de> |
Hello,
I use DateTime::Format::Pg and tried to parse a time without time zone
via
DateTime::Format::Pg->parse_datetime('12:00:00');
This throws me a warning:
Use of uninitialized value in numeric lt (<)
at /usr/share/perl5/DateTime/Format/Pg.pm line 324
sub _fix_timezone
This happens, because the year field in extra is not yet added to the
parsed hash and the time_zone is undefined. I could use parse_time, but
I want to keep parse_datetime for parsing my date and time values.
Is it possible to fix it upstream?
I just added following:
if(!defined($args{'parsed'}->{'time_zone'})) {
# For very early and late dates, PostgreSQL always returns times in
# UTC and does not tell us that it did so.
+ if (! defined $args{'parsed'} ) {
+ # time without timezone, so add floating, see parse_time
+ $args{'parsed'}->{'time_zone'} = 'floating';
+ }
+
+ elsif ( $args{'parsed'}->{'year'} < 1901
- if ( $args{'parsed'}->{'year'} < 1901
|| ( $args{'parsed'}->{'year'} == 1901 && ($args{'parsed'}->{'month'} < 12 || $args{'parsed'}->{'day'} < 14) )
Regards
Gerhard Heift
Message body not shown because it is not plain text.