Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime-Format-Pg CPAN distribution.

Report information
The Basics
Id: 44594
Status: new
Priority: 0/
Queue: DateTime-Format-Pg

People
Owner: Nobody in particular
Requestors: jonas [...] paranormal.se
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.16002
Fixed in: (no value)



Subject: Failes to parse Pg date with BC (patch included)
While testing a couple of unusual dates, I got an error trying to parse "1221-01-01 00:00:00+01 BC" It seems that the module expected tz after the era instead of before. I changed the module and created a test for it. I assume that BC comes last also for the other formats. The test case was for $pg_datetime_iso. / Jonas
Subject: Pg.pm.diff
--- lib/DateTime/Format/Pg.pm.orig 2009-03-26 11:28:43.000000000 +0100 +++ lib/DateTime/Format/Pg.pm 2009-03-26 11:48:40.000000000 +0100 @@ -225,47 +225,47 @@ # (NB: always uses numerical tz) # my $pg_datetime_iso = { - regex => qr/^(\d{4,})-(\d{2,})-(\d{2,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)?( BC)? *([-\+][\d:]+)?$/, - params => [ qw( year month day hour minute second nanosecond era time_zone) ], + regex => qr/^(\d{4,})-(\d{2,})-(\d{2,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)? *([-\+][\d:]+)?( BC)?$/, + params => [ qw( year month day hour minute second nanosecond time_zone era) ], postprocess => [ \&_fix_era, \&_fix_timezone, \&_fix_nanosecond ], }; # Fri 18 Apr 17:20:24.373942 2003 CEST (USE_POSTGRES_DATES, EuroDates) # my $pg_datetime_pg_eu = { - regex => qr/^\S{3,} (\d{2,}) (\S{3,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)? (\d{4,})( BC)? *((?:[-\+][\d:]+)|(?:\S+))?$/, - params => [ qw( day month hour minute second nanosecond year era time_zone) ], + regex => qr/^\S{3,} (\d{2,}) (\S{3,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)? (\d{4,}) *((?:[-\+][\d:]+)|(?:\S+))?( BC)?$/, + params => [ qw( day month hour minute second nanosecond year time_zone era ) ], postprocess => [ \&_fix_era, \&_fix_timezone, \&_fix_nanosecond ], }; # Fri Apr 18 17:20:24.373942 2003 CEST (USE_POSTGRES_DATES, !EuroDates) # my $pg_datetime_pg_us = { - regex => qr/^\S{3,} (\S{3,}) (\s{2,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)? (\d{4,})( BC)? *((?:[-\+][\d:]+)|(?:\S+))?$/, - params => [ qw( month day hour minute second nanosecond year era time_zone) ], + regex => qr/^\S{3,} (\S{3,}) (\s{2,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)? (\d{4,}) *((?:[-\+][\d:]+)|(?:\S+))?( BC)?$/, + params => [ qw( month day hour minute second nanosecond year time_zone era ) ], postprocess => [ \&_fix_era, \&_fix_month_names, \&_fix_timezone, \&_fix_nanosecond ], }; # 18/04/2003 17:20:24.373942 CEST (USE_SQL_DATES, EuroDates) # 04/18/2003 17:20:24.373942 CEST (USE_SQL_DATES, !EuroDates) # my $pg_datetime_sql = { - regex => qr/^(\d{2,})\/(\d{2,})\/(\d{4,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)?( BC)? *((?:[-\+][\d:]+)|(?:\S+))?$/, - params => [ qw( month day year hour minute second nanosecond era time_zone) ], + regex => qr/^(\d{2,})\/(\d{2,})\/(\d{4,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)? *((?:[-\+][\d:]+)|(?:\S+))?( BC)?$/, + params => [ qw( month day year hour minute second nanosecond time_zone era ) ], postprocess => [ \&_fix_era, \&_fix_eu, \&_fix_timezone, \&_fix_nanosecond ], }; # 18.04.2003 17:20:24.373942 CEST (USE_GERMAN_DATES) # my $pg_datetime_german = { - regex => qr/^(\d{2,})\.(\d{2,})\.(\d{4,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)?( BC)? *((?:[-\+][\d:]+)|(?:\S+))?$/, - params => [ qw( day month year hour minute second nanosecond era time_zone) ], + regex => qr/^(\d{2,})\.(\d{2,})\.(\d{4,}) (\d{2,}):(\d{2,}):(\d{2,})(\.\d+)? *((?:[-\+][\d:]+)|(?:\S+))?( BC)?$/, + params => [ qw( day month year hour minute second nanosecond time_zone era ) ], postprocess => [ \&_fix_era, \&_fix_timezone, \&_fix_nanosecond ], }; # Helper functions
Subject: parse_datetime3.t
# $Id: $ use Test::More tests => 8; use DateTime::Format::Pg 0.02; { my $dt = DateTime::Format::Pg->parse_datetime('1221-01-02 03:04:05+01 BC'); is($dt->year(), -1220, 'year'); is($dt->month(), 01, 'month'); is($dt->day(), 02, 'day'); is($dt->hour(), 03, 'hour'); is($dt->minute(), 04, 'minute'); is($dt->second(), 05, 'second'); is($dt->nanosecond(), 00, 'nanosecond'); is($dt->offset(), (1*60)*60, 'tz offset'); }