Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
Fix reading of 1904 dates option
Browse files Browse the repository at this point in the history
Whether the spreadsheet is using 1904 dates or not is controlled by a XML property. Its value can be the string "false" that is not mapped to the boolean "false" but to the boolean "true"... Therefore Spout was previously using the wrong date system when this property was set.
  • Loading branch information
adrilo committed Jun 4, 2019
1 parent a296f73 commit 6c4086c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Spout/Reader/XLSX/Manager/SheetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public function getSheets()
*/
protected function processWorkbookPropertiesStartingNode($xmlReader)
{
$shouldUse1904Dates = (bool) $xmlReader->getAttribute(self::XML_ATTRIBUTE_DATE_1904);
// Using "filter_var($x, FILTER_VALIDATE_BOOLEAN)" here because the value of the "date1904" attribute
// may be the string "false", that is not mapped to the boolean "false" by default...
$shouldUse1904Dates = filter_var($xmlReader->getAttribute(self::XML_ATTRIBUTE_DATE_1904), FILTER_VALIDATE_BOOLEAN);
$this->optionsManager->setOption(Options::SHOULD_USE_1904_DATES, $shouldUse1904Dates);

return XMLProcessor::PROCESSING_CONTINUE;
Expand Down

0 comments on commit 6c4086c

Please sign in to comment.