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

Commit 6c4086c

Browse files
committed
Fix reading of 1904 dates option
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.
1 parent a296f73 commit 6c4086c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Spout/Reader/XLSX/Manager/SheetManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ public function getSheets()
114114
*/
115115
protected function processWorkbookPropertiesStartingNode($xmlReader)
116116
{
117-
$shouldUse1904Dates = (bool) $xmlReader->getAttribute(self::XML_ATTRIBUTE_DATE_1904);
117+
// Using "filter_var($x, FILTER_VALIDATE_BOOLEAN)" here because the value of the "date1904" attribute
118+
// may be the string "false", that is not mapped to the boolean "false" by default...
119+
$shouldUse1904Dates = filter_var($xmlReader->getAttribute(self::XML_ATTRIBUTE_DATE_1904), FILTER_VALIDATE_BOOLEAN);
118120
$this->optionsManager->setOption(Options::SHOULD_USE_1904_DATES, $shouldUse1904Dates);
119121

120122
return XMLProcessor::PROCESSING_CONTINUE;

0 commit comments

Comments
 (0)