lestrrat-p5 / DateTime-Format-Pg

Other
2 stars 5 forks source link

parse_duration not handling fractions of a second. #12

Closed yewtc closed 8 years ago

yewtc commented 8 years ago

V 0.16012, OS Fedora 23 perl 5.22.1

As it says. DateTime::Format::Pg->parse_duration('1095 days 13:37:28.369224') results in Unknown timespec: 1095 days 13:37:28.369224. Under the debugger it looks like it's the .369224 bit that it is complaining about. ( It might have been clearer if I could have seen that more directly in the error message).

It looks like the code around lines 593-596 is not taking fractional seconds into account.

lestrrat commented 8 years ago

can you please provide a failing test?

yewtc commented 8 years ago

I tried to upload the file, but I couldn't upload a *.t file. (This passes at 0.160011).

use strict;
use warnings;

use Test::More;
use Test::Exception;

BEGIN {
    use_ok('DateTime::Format::Pg');
};

my $offset = '1095 days 13:37:28.369224';

my $duration;
lives_ok {
    $duration = DateTime::Format::Pg->parse_duration($offset);
} "Lives ok";

done_testing;