nuovo / spreadsheet-reader

A PHP spreadsheet reader (Excel XLS and XLSX, OpenOffice ODS, and variously separated text files) with a singular goal of getting the data out, efficiently
http://www.nuovo.lv/
Other
674 stars 498 forks source link

Precision issue on minutes #159

Open fellwell5 opened 5 years ago

fellwell5 commented 5 years ago

I experienced an issue that showed me minutes wrong.

I have in an .xlsx file in a cell (formatted general) this entry "03.01.2019 16:00" (without the "), but I'm getting "03.01.2019 15:59". In the cell below i have "04.01.2019 18:00" and i get the right value.

I added one line in the SpreadsheetReader_XLSX.php file: on line 841: $Seconds = $Seconds + 1;

// At this point time is a fraction of a day $Time = ($Value - (int)$Value); $Seconds = 0; if ($Time) { // Here time is converted to seconds // Some loss of precision will occur $Seconds = (int)($Time * 86400); $Seconds = $Seconds + 1; // I added this line }

Now i get every time right. Please take not that i DON'T use seconds in my timestamps.