bastiam / php-excel-reader2

Automatically exported from code.google.com/p/php-excel-reader2
0 stars 0 forks source link

Time values of hh:mm aren't being parsed correctly #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Load spreadsheet with time values of the format hh:mm. e.g., 
http://www.westhighlandwayrace.org/2012results.xls
2.Dump the spreadsheet contents

What is the expected output? What do you see instead?
Most time values appear correct, but some are completely wrong. e.g.,
119 Harry McAlinden should be

04:08   133     11:10   148     14:47   151     17:44   135     21:47   138     27:10   125 
    34:15:28    119     

but instead has

4:08    133     11:10   148     2:47    151     17:44   135     21:47   138     :12     125     34:15:28 
    119      

What version of the product are you using? On what operating system?
v2.22, CentOS 6 Linux

Please provide any additional information below.
It isn't as simple as time larger than 12 hrs or 24 hrs going wrong, as most 
larger time values work fine. The $format for the incorrect values is either 
"g:i" or ":m", so there is a bug somewhere in the code generating these strange 
$format strings.

A bodged workaround until there is a proper fix is:

      $days = floor ( $numValue );
      if ($format == "g:i" || $format == ":m"):
        $hours += $days*24;
        $string = sprintf("%02d:%02d", $hours, $mins);
      else:
        $string = date ( $format, mktime ( $hours, $mins, $secs, $dateinfo ["mon"], $dateinfo ["mday"], $dateinfo ["year"] ) );
      endif;

Original issue reported on code.google.com by nickcons...@googlemail.com on 18 Apr 2013 at 8:52