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: 18487
Status: new
Priority: 0/
Queue: DateTime-Format-Pg

People
Owner: Nobody in particular
Requestors: siracusa [...] mindspring.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.10
Fixed in: (no value)



Subject: Incorrect handling of fractional seconds
Fractional seconds are not formatted corrrectly. Example: --- use strict; use DateTime::Duration; use DateTime::Format::Pg; my $dur = DateTime::Duration->new(nanoseconds => 3000); my $val = DateTime::Format::Pg->format_duration($dur); # $val is now "@ 3e-06 seconds" which is not a valid INTERVAL column value --- Here's a patch to fix it and to add a test for the bug: --- diff -u lib/DateTime/Format/Pg.pm lib/DateTime/Format/Pg.pm.new --- lib/DateTime/Format/Pg.pm 2006-01-06 19:46:20.000000000 -0500 +++ lib/DateTime/Format/Pg.pm.new 2006-03-31 16:03:25.000000000 -0500 @@ -791,9 +791,9 @@ my $output = '@'; if($deltas{'nanoseconds'}) { - $deltas{'seconds'} += - $deltas{'nanoseconds'} / - DateTime::Duration::MAX_NANOSECONDS; + $deltas{'seconds'} = + sprintf('%f', $deltas{'seconds'} + $deltas{'nanoseconds'} / + DateTime::Duration::MAX_NANOSECONDS); } foreach(qw(months days minutes seconds)) { diff -u t/format_interval.t t/format_interval.t.new --- t/format_interval.t 2005-03-16 11:50:40.000000000 -0500 +++ t/format_interval.t.new 2006-03-31 16:07:06.000000000 -0500 @@ -1,5 +1,5 @@ # $Id: format_interval.t,v 1.1 2005/03/16 16:50:40 cfaerber Exp $ -use Test::More tests => 3; +use Test::More tests => 4; use DateTime 0.10; use DateTime::Duration; use DateTime::Format::Pg 0.02; @@ -17,6 +17,10 @@ hours => 1, minutes => 61, seconds => 61, }, + + '@ 1 months 0.000003 seconds' => { + months => 1, + nanoseconds => 3000, }, ); foreach my $result (keys %tests) { ---