Skip Menu |

This queue is for tickets about the Finance-Quote CPAN distribution.

Report information
The Basics
Id: 40215
Status: resolved
Estimated: 5 min
Worked: 5 min
Priority: 0/
Queue: Finance-Quote

People
Owner: eco [...] ecocode.net
Requestors: dbreiser [...] gmail.com
Cc:
AdminCc:

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



Subject: isoTime bug for minutes :00 through :09 in requests from gnucash
The isoTime function in Quote.pm breaks quote retrieval in gnucash for at least yahoo sources in US and Europe for times having minutes less than 10. (Virtually every end-of-day quote in the US at least.) If the Yahoo source sends a time value of "4:00pm" (with the quotes), finance-quote sends 16:000 to gnucash. The gnucash parser then refuses the quote as unusable. sub isoTime { my ($self,$timeString) = @_ ; $timeString =~ tr/ //d ; $timeString = uc $timeString ; my $retTime = "00:00"; # return zero time if unparsable input if ($timeString=~m/^(\d+)[\.:UH](\d+)(AM|PM)?/) { my ($hours,$mins)= ($1,$2) ; $hours+=12 if ($3 && ($3 eq "PM")) ; if ($hours>=0 && $hours<=23 && $mins>=0 && $mins<=59 ) { $retTime = $hours>=10 ? "$hours:" : "0$hours:" ; $retTime.= $mins>=10 ? "$mins" :"0$mins" ; } If I change the "0$mins" to just "$mins" gnucash quits complaining, and I can retrieve quotes again. Shouldn't that last line be: $retTime.= "$mins" ; ? or are there time sources that return things like 12H 3M ?
Apologies for this being a super-short comment, I have a deadline in 30 minutes to hit. On Tue Oct 21 01:22:27 2008, dbreiser wrote: Show quoted text
> if ($hours>=0 && $hours<=23 && $mins>=0 && $mins<=59 ) { > $retTime = $hours>=10 ? "$hours:" : "0$hours:" ; > $retTime.= $mins>=10 ? "$mins" :"0$mins" ; > }
Ideally we should be using sprintf to do this work, rather than trying to add our own zeros: $retTime = "%02d:%02d", $hours, $mins;
Subject: Re: [rt.cpan.org #40215] isoTime bug for minutes :00 through :09 in requests from gnucash
Date: Tue, 21 Oct 2008 07:48:05 +0200
To: bug-Finance-Quote [...] rt.cpan.org
From: Erik Colson <eco [...] ecocode.net>
PJF via RT wrote: Show quoted text
> Ideally we should be using sprintf to do this work, rather than trying > to add our own zeros: > > $retTime = "%02d:%02d", $hours, $mins; > >
yep, you are right. The bug is due to $hours and $mins being treated as strings instead of numbers. A patch has been commited. and some tests added. Regards -- Erik Colson http://www.ecocode.net