diff -Nru libdatetime-format-pg-perl-0.16012/Changes libdatetime-format-pg-perl-0.16013/Changes --- libdatetime-format-pg-perl-0.16012/Changes 2016-07-19 21:37:34.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/Changes 2017-05-04 12:46:26.000000000 +0000 @@ -1,8 +1,12 @@ Revision history for Perl extension DateTime::Format::Pg. +0.16013 2017-05-04T12:46:23Z + - Fix handling for nanoseconds (issue #14) + - Fix handling fractional seconds (issue #12) + 0.16012 2016-07-19T21:37:31Z - Parsing invalid intervals with no amount and units only should have - resulted in exceptions, but did not. Reported by Henrik Pauli (ssue #8) + resulted in exceptions, but did not. Reported by Henrik Pauli (issue #8) - Internal cleanup 0.16011 2015-06-19T13:40:27Z diff -Nru libdatetime-format-pg-perl-0.16012/debian/changelog libdatetime-format-pg-perl-0.16013/debian/changelog --- libdatetime-format-pg-perl-0.16012/debian/changelog 2016-07-20 18:04:30.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/debian/changelog 2017-08-03 02:17:11.000000000 +0000 @@ -1,3 +1,14 @@ +libdatetime-format-pg-perl (0.16013-1) unstable; urgency=medium + + * Remove Jonathan Yu from Uploaders. Thanks for your work! + * Remove Rene Mayorga from Uploaders. Thanks for your work! + * Import upstream version 0.16013. + * Drop spelling.patch, merged upstream. + * Update years of packaging copyright. + * Declare compliance with Debian Policy 4.0.0. + + -- gregor herrmann Wed, 02 Aug 2017 22:17:11 -0400 + libdatetime-format-pg-perl (0.16012-1) unstable; urgency=medium [ Salvatore Bonaccorso ] diff -Nru libdatetime-format-pg-perl-0.16012/debian/control libdatetime-format-pg-perl-0.16013/debian/control --- libdatetime-format-pg-perl-0.16012/debian/control 2016-07-20 18:04:30.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/debian/control 2017-08-03 02:17:11.000000000 +0000 @@ -2,9 +2,7 @@ Maintainer: Debian Perl Group Uploaders: Krzysztof Krzyzaniak (eloy) , gregor herrmann , - Rene Mayorga , - Ansgar Burchardt , - Jonathan Yu + Ansgar Burchardt Section: perl Testsuite: autopkgtest-pkg-perl Priority: optional @@ -16,7 +14,7 @@ libtest-pod-coverage-perl, libtest-pod-perl, perl -Standards-Version: 3.9.8 +Standards-Version: 4.0.0 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-perl/packages/libdatetime-format-pg-perl.git Vcs-Git: https://anonscm.debian.org/git/pkg-perl/packages/libdatetime-format-pg-perl.git Homepage: https://metacpan.org/release/DateTime-Format-Pg diff -Nru libdatetime-format-pg-perl-0.16012/debian/copyright libdatetime-format-pg-perl-0.16013/debian/copyright --- libdatetime-format-pg-perl-0.16012/debian/copyright 2016-07-20 18:04:30.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/debian/copyright 2017-08-03 02:17:11.000000000 +0000 @@ -11,7 +11,7 @@ Files: debian/* Copyright: - 2006-2016, gregor herrmann + 2006-2017, gregor herrmann 2007, Krzysztof Krzyzaniak (eloy) 2007-2008, Rene Mayorga 2009, Jonathan Yu diff -Nru libdatetime-format-pg-perl-0.16012/debian/patches/series libdatetime-format-pg-perl-0.16013/debian/patches/series --- libdatetime-format-pg-perl-0.16012/debian/patches/series 2016-07-20 18:04:30.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -spelling.patch diff -Nru libdatetime-format-pg-perl-0.16012/debian/patches/spelling.patch libdatetime-format-pg-perl-0.16013/debian/patches/spelling.patch --- libdatetime-format-pg-perl-0.16012/debian/patches/spelling.patch 2016-07-20 18:04:30.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/debian/patches/spelling.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -Description: spelling fix -Origin: vendor -Author: gregor herrmann -Last-Update: 2016-07-20 -Forwarded: https://github.com/lestrrat/DateTime-Format-Pg/issues/10 -Bug: https://github.com/lestrrat/DateTime-Format-Pg/issues/10 - ---- a/lib/DateTime/Format/Pg.pm -+++ b/lib/DateTime/Format/Pg.pm -@@ -862,7 +862,7 @@ - - If DateStyle is set to 'PostgreSQL', 'SQL', or 'German', PostgreSQL does - not send numerical time zones for the TIMESTAMPTZ (or TIMESTAMP WITH --TIME ZONE) type. Unfortunatly, the time zone names used instead can be -+TIME ZONE) type. Unfortunately, the time zone names used instead can be - ambiguous: For example, 'EST' can mean -0500, +1000, or +1100. - - You must set the 'server_tz' variable to a time zone that is identical to that diff -Nru libdatetime-format-pg-perl-0.16012/lib/DateTime/Format/Pg.pm libdatetime-format-pg-perl-0.16013/lib/DateTime/Format/Pg.pm --- libdatetime-format-pg-perl-0.16012/lib/DateTime/Format/Pg.pm 2016-07-19 21:37:34.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/lib/DateTime/Format/Pg.pm 2017-05-04 12:46:26.000000000 +0000 @@ -11,7 +11,7 @@ use DateTime::TimeZone::UTC; use DateTime::TimeZone::Floating; -$VERSION = '0.16012'; +$VERSION = '0.16013'; $VERSION = eval $VERSION; our @ISA = ('DateTime::Format::Builder'); @@ -368,7 +368,7 @@ sub _fix_nanosecond { my %args = @_; if(defined $args{'parsed'}->{'nanosecond'}) { - $args{'parsed'}->{'nanosecond'} *= 1.0E9; + $args{'parsed'}->{'nanosecond'} = sprintf '%.0f', $args{'parsed'}->{'nanosecond'} * 1.0E9; } else { delete $args{'parsed'}->{'nanosecond'} }; @@ -581,40 +581,58 @@ (my $string = $string_to_parse) =~ s/^@\s*//; $string =~ s/\+(\d+)/$1/g; - my $subtract = 0; + # Method used later on duration object + my $arith_method = "add"; if ( $string =~ s/ago// ) { - $subtract = 1; + $arith_method = "subtract"; } my $sign = 0; my %done; -# $timespec =~ s/\b(\d+):(\d\d):((\d\d)|(\d\d.\d+))\b/$1h $2m $3s/g; - $string =~ s/\b(\d+):(\d\d):(\d\d)\b/$1h $2m $3s/g; + $string =~ s/\b(\d+):(\d\d):(\d\d)(\.\d+)?\b/$1h $2m $3$4s/g; $string =~ s/\b(\d+):(\d\d)\b/$1h $2m/g; $string =~ s/(-\d+h)\s+(\d+m)\s+(\d+s)\s*/$1 -$2 -$3 /; $string =~ s/(-\d+h)\s+(\d+m)\s*/$1 -$2 /; while ($string =~ s/^\s*(-?\d+(?:[.,]\d+)?)\s*([a-zA-Z]+)(?:\s*(?:,|and)\s*)*//i) { my($amount, $unit) = ($1, $2); - $unit = lc($unit) unless length($unit) == 1; + if (length($unit) != 1) { + $unit = lc($unit); + } + + my $udata = $units{$unit}; + if (! $udata) { + Carp::croak("Unknown timespec: $string_to_parse"); + } + my ($base_unit, $num) = @$udata; + my $key = $base_unit . "-" . $num; + if (exists $done{$key}) { + Carp::croak("Unknown timespec: $string_to_parse"); + } + $done{$key} = 1; - my ($base_unit, $num); - if ( defined( $units{$unit} ) ) { - ($base_unit, $num) = @{$units{$unit}}; - my $key = $base_unit . "-" . $num; - Carp::croak "Unknown timespec: $string_to_parse" if defined($done{$key}); - $done{$key} = 1; - - $amount =~ s/,/./; - if ( $subtract ) { - $du->subtract( $base_unit => $amount * $num ); - } else { - $du->add( $base_unit => $amount * $num ); + my @extra_args; + + $amount =~ s/,/./; + if ($amount =~ s/\.(\d+)$//) { + my $fractional = $1; + # We only handle fractional seconds right now. If you + # need support for silly formats (from my perspective ;-P) + # like '1.5 weeks', please provide me with a comprehensive + # test for all possible combinations of fractional times. + if ($base_unit ne "seconds") { + Carp::croak("Fractional input detected: currently only fractional seconds are supported") } - } else { - Carp::croak "Unknown timespec: $string_to_parse"; + + # From the spec, Pg can take up to 6 digits for fractional part + # (duh, as 1 sec = 1_000_000 nano sec). If we're missing 0's, + # we should pad them + $fractional .= '0'x (6 - length($fractional)); + push @extra_args, ("nanoseconds" => $fractional); } + + $du->$arith_method($base_unit => $amount * $num, @extra_args); } if ($string =~ /\S/) { # OK to have extra spaces, but nothing else @@ -862,7 +880,7 @@ If DateStyle is set to 'PostgreSQL', 'SQL', or 'German', PostgreSQL does not send numerical time zones for the TIMESTAMPTZ (or TIMESTAMP WITH -TIME ZONE) type. Unfortunatly, the time zone names used instead can be +TIME ZONE) type. Unfortunately, the time zone names used instead can be ambiguous: For example, 'EST' can mean -0500, +1000, or +1100. You must set the 'server_tz' variable to a time zone that is identical to that diff -Nru libdatetime-format-pg-perl-0.16012/MANIFEST libdatetime-format-pg-perl-0.16013/MANIFEST --- libdatetime-format-pg-perl-0.16012/MANIFEST 2016-07-19 21:37:34.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/MANIFEST 2017-05-04 12:46:26.000000000 +0000 @@ -14,11 +14,13 @@ t/format_datetime.t t/format_fractional.t t/format_interval.t +t/gh12.t t/parse_date.t t/parse_datetime.t t/parse_datetime2.t t/parse_datetime3.t t/parse_datetime4.t +t/parse_datetime5.t t/parse_infinity.t t/parse_interval.t t/parse_time.t diff -Nru libdatetime-format-pg-perl-0.16012/META.json libdatetime-format-pg-perl-0.16013/META.json --- libdatetime-format-pg-perl-0.16012/META.json 2016-07-19 21:37:34.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/META.json 2017-05-04 12:46:26.000000000 +0000 @@ -57,7 +57,7 @@ "provides" : { "DateTime::Format::Pg" : { "file" : "lib/DateTime/Format/Pg.pm", - "version" : "0.16012" + "version" : "0.16013" } }, "release_status" : "stable", @@ -71,12 +71,13 @@ "web" : "https://github.com/lestrrat/DateTime-Format-Pg" } }, - "version" : "0.16012", + "version" : "0.16013", "x_contributors" : [ "Vasily Chekalkin ", "David Steinbrunner ", "Henrik Pauli ", "Nitish Bezzala ", + "Ilya Chesnokov ", "lestrrat " ] } diff -Nru libdatetime-format-pg-perl-0.16012/META.yml libdatetime-format-pg-perl-0.16013/META.yml --- libdatetime-format-pg-perl-0.16012/META.yml 2016-07-19 21:37:34.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/META.yml 2017-05-04 12:46:26.000000000 +0000 @@ -27,7 +27,7 @@ provides: DateTime::Format::Pg: file: lib/DateTime/Format/Pg.pm - version: '0.16012' + version: '0.16013' requires: DateTime: '0.10' DateTime::Format::Builder: '0.72' @@ -36,10 +36,11 @@ bugtracker: https://github.com/lestrrat/DateTime-Format-Pg/issues homepage: https://github.com/lestrrat/DateTime-Format-Pg repository: git://github.com/lestrrat/DateTime-Format-Pg.git -version: '0.16012' +version: '0.16013' x_contributors: - 'Vasily Chekalkin ' - 'David Steinbrunner ' - 'Henrik Pauli ' - 'Nitish Bezzala ' + - 'Ilya Chesnokov ' - 'lestrrat ' diff -Nru libdatetime-format-pg-perl-0.16012/README.md libdatetime-format-pg-perl-0.16013/README.md --- libdatetime-format-pg-perl-0.16012/README.md 2016-07-19 21:37:34.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/README.md 2017-05-04 12:46:26.000000000 +0000 @@ -269,7 +269,7 @@ If DateStyle is set to 'PostgreSQL', 'SQL', or 'German', PostgreSQL does not send numerical time zones for the TIMESTAMPTZ (or TIMESTAMP WITH -TIME ZONE) type. Unfortunatly, the time zone names used instead can be +TIME ZONE) type. Unfortunately, the time zone names used instead can be ambiguous: For example, 'EST' can mean -0500, +1000, or +1100. You must set the 'server\_tz' variable to a time zone that is identical to that diff -Nru libdatetime-format-pg-perl-0.16012/t/gh12.t libdatetime-format-pg-perl-0.16013/t/gh12.t --- libdatetime-format-pg-perl-0.16012/t/gh12.t 1970-01-01 00:00:00.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/t/gh12.t 2017-05-04 12:46:26.000000000 +0000 @@ -0,0 +1,20 @@ +use strict; +use Test::More; + +use_ok('DateTime::Format::Pg'); + +# https://www.postgresql.org/docs/9.5/static/datatype-datetime.html#DATATYPE-INTERVAL-INPUT +my $offset = '1095 days 13:37:28.36922'; +my $duration; +eval { + $duration = DateTime::Format::Pg->parse_duration($offset); +}; +my $e = $@; +if (! ok !$e, "should succeed parsing '$offset' without errors") { + diag $e; +} + +is $duration->seconds, 28, "seconds should be '28'"; +is $duration->nanoseconds, 369220, "seconds should be '369220'"; + +done_testing; \ No newline at end of file diff -Nru libdatetime-format-pg-perl-0.16012/t/parse_datetime5.t libdatetime-format-pg-perl-0.16013/t/parse_datetime5.t --- libdatetime-format-pg-perl-0.16012/t/parse_datetime5.t 1970-01-01 00:00:00.000000000 +0000 +++ libdatetime-format-pg-perl-0.16013/t/parse_datetime5.t 2017-05-04 12:46:26.000000000 +0000 @@ -0,0 +1,10 @@ +use Test::More tests => 1; +use DateTime::Format::Pg 0.02; + +# This test fails when nanosecond is not converted properly to an integer. This +# happens when the fractional part of timestamp is .254182 - got this number by +# experiment. +{ + my $dt = DateTime::Format::Pg->parse_datetime('2017-05-02 12:39:10.254182+00'); + cmp_ok($dt->nanosecond(), '==', 254182000, 'nanosecond as a number'); +}