Skip Menu |

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

Report information
The Basics
Id: 58854
Status: resolved
Priority: 0/
Queue: DateTime-Format-HTTP

People
Owner: Nobody in particular
Requestors: ckras [...] cpan.org
Cc:
AdminCc:

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



Subject: Calculated nanoseconds not always an integer
The calculated nanoseconds sometimes results in a float making creating the DateTime object fail. perl -MDateTime::Format::HTTP -E "my $dt = DateTime::Format::HTTP->parse_datetime('2010-06-26T15:14:33.400753');" This is currently what's causing another bug in Net::Mosso::CloudFiles as well (RT#48561). If you add '2010-06-26T15:14:33.400753' to @tests in date.t you can see it fail. I've tried forcing the conversion of the nanoseconds value to an integer, but that results in a time difference when running the tests.
Any interest in co-maint on this module? I don't really use it myself.
Let me see if I can come up with a fix first. I'll try to have a look at it this week.
This was actually quite easy to fix. Here's the patch. I had added another entry to the @tests array, which I later found out are only for those 1994 dates. In the end all I had to do was convert the nanosecond value to a integer. I added a test for the earlier mentioned date. All tests seem to run fine. Being a co-maintainer is fine, but I'm not very familiar with dates and such so I'm not sure if I can be of much help when required.
Subject: rt_58854.patch
From a8a6390912463657da65b158a21a4828f6f6c399 Mon Sep 17 00:00:00 2001 From: Htbaa <c.kras@pcc-online.net> Date: Mon, 28 Jun 2010 20:58:30 +0200 Subject: Fixed RT#58854 --- Changes | 5 +++++ lib/DateTime/Format/HTTP.pm | 2 +- t/date.t | 9 ++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 77b7705..47dc0bd 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,8 @@ +0.39 2010-06-28 + +- Making sure the nanosecond is a integer, and not a float making the creation + of a DateTime object fail. Fixes RT 58854 (Christiaan Kras) + 0.38 2009-04-05 - No code changes from previous versions. diff --git a/lib/DateTime/Format/HTTP.pm b/lib/DateTime/Format/HTTP.pm index 4920d29..9185d53 100644 --- a/lib/DateTime/Format/HTTP.pm +++ b/lib/DateTime/Format/HTTP.pm @@ -54,7 +54,7 @@ sub parse_datetime } my $frac = $d{second}; $frac -= ($d{second} = int($frac)); - my $nano = 100_000_000 * $frac; $d{nanosecond} = $nano; + my $nano = 100_000_000 * $frac; $d{nanosecond} = int($nano); return DateTime->new( %d ); } diff --git a/t/date.t b/t/date.t index a07a908..3162249 100644 --- a/t/date.t +++ b/t/date.t @@ -1,7 +1,7 @@ #!/usr/bin/perl -w use strict; use lib 'inc'; -use Test::More tests => 115; +use Test::More tests => 116; use vars qw( $class ); BEGIN { @@ -152,6 +152,13 @@ ok( "FRAC $t = ".$class->format_iso($dt) ); +$dt = $class->parse_datetime("2010-06-26T15:14:33.400753"); +$t = $dt->epoch; +ok( + abs(($t - int($t)) - 0.400753) > 0.000001, + "FRAC $t = ".$class->format_iso($dt) +); + $a = $class->format_iso( ); $b = $class->format_iso( DateTime->from_epoch( epoch => 500000 ) ); -- 1.7.0.2.msysgit.0
If giving me co-maintainership is easier for you then I'd be glad to do a new release.
On Tue Jun 29 13:41:42 2010, CKRAS wrote: Show quoted text
> If giving me co-maintainership is easier for you then I'd be glad to do > a new release.
Great, a couple things ... One, you need a PAUSE id so I can give you co-maint (http://pause.perl.org). Two, the source is currently in Sourceforge SVN. I'd be happy to help move it somewhere else (github, bitbucket, whatever), or I can give you access to the sourceforge project.
Well if I may choose I prefer GitHub. Always found Sourceforge a confusing website and I prefer Git over SVN. I believe GitHub has a service to import from a SVN hosted repository. My PAUSE ID is CKRAS. At GitHub my account is Htbaa. PS: Thanks for the prompt responses to this ticket. Haven't been this lucky with some other module...
Subject: Re: [rt.cpan.org #58854] Calculated nanoseconds not always an integer
Date: Tue, 29 Jun 2010 16:05:52 -0500 (CDT)
To: Christiaan Kras via RT <bug-DateTime-Format-HTTP [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Tue, 29 Jun 2010, Christiaan Kras via RT wrote: Show quoted text
> Well if I may choose I prefer GitHub. Always found Sourceforge a > confusing website and I prefer Git over SVN. I believe GitHub has a > service to import from a SVN hosted repository.
If you already have a github id you should try importing. The trick will be to get just a chunk of the big repo imported. The root is https://perl-date-time.svn.sourceforge.net/svnroot/perl-date-time/modules/DateTime-Format-HTTP Show quoted text
> My PAUSE ID is CKRAS.
You have co-maint now. Show quoted text
> PS: Thanks for the prompt responses to this ticket. Haven't been this > lucky with some other module...
I'm happy to give away responsibility ;) -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
http://github.com/Htbaa/DateTime-Format-HTTP GitHub is trying its best to create the Git repo. Although I gave the exact URL I fear it's cloning everything from root. Just have to wait and see. If you happen to be on GitHub I can add you as a collaborator. Will try to apply the patch later this week. After that I'll upload a dev. release first. If the test results are good I'll do a proper release. Just wondering, do I have to change the author info in Build.PL?
Subject: Re: [rt.cpan.org #58854] Calculated nanoseconds not always an integer
Date: Wed, 30 Jun 2010 14:29:41 -0500 (CDT)
To: Christiaan Kras via RT <bug-DateTime-Format-HTTP [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Wed, 30 Jun 2010, Christiaan Kras via RT wrote: Show quoted text
> GitHub is trying its best to create the Git repo. Although I gave the > exact URL I fear it's cloning everything from root. Just have to wait > and see.
Well, the URL I gave you wasn't the repo root, so hopefully it does the right thing. Show quoted text
> If you happen to be on GitHub I can add you as a collaborator. Will try > to apply the patch later this week. After that I'll upload a dev. > release first. If the test results are good I'll do a proper release.
I'm autarch on github. Show quoted text
> Just wondering, do I have to change the author info in Build.PL?
Yes, you should. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
I successfully ported the repository to Git. Have uploaded 0.38_01 to receive some test feedback first.