Subject: | Misparses times 12:00pm to 12:59pm |
If the time of last trade is reported by yahoo as 12:XXpm, with XX
replaced by any numbers, Finance::Quote returns time 00:00. That's
because it computes a time of 24:XX, recognises it as invalid and falls
back to 00:00.
Here is a patch that fixes the problem.
Subject: | 44245.patch |
diff -u --recursive libfinance-quote-perl-1.15/lib/Finance/Quote.pm /usr/share/perl5/Finance/Quote.pm
--- libfinance-quote-perl-1.15/lib/Finance/Quote.pm 2008-10-26 09:15:50.000000000 +0100
+++ /usr/share/perl5/Finance/Quote.pm 2009-03-17 18:44:49.657872693 +0100
@@ -671,7 +671,14 @@
my $retTime = "00:00"; # return zero time if unparsable input
if ($timeString=~m/^(\d+)[\.:UH](\d+)(AM|PM)?/) {
my ($hours,$mins)= ($1-0,$2-0) ;
- $hours+=12 if ($3 && ($3 eq "PM")) ;
+ if ($hours==12) {
+ if ($3 && ($3 eq "AM")) {
+ $hours=0;
+ }
+ }
+ elsif ($3 && ($3 eq "PM")) {
+ $hours+=12;
+ }
if ($hours>=0 && $hours<=23 && $mins>=0 && $mins<=59 ) {
$retTime = sprintf ("%02d:%02d", $hours, $mins) ;
}