nulib-spout/patches/v4.27.0-000-date-format.patch

34 lines
1.6 KiB
Diff

diff --git a/src/Reader/XLSX/Helper/CellValueFormatter.php b/src/Reader/XLSX/Helper/CellValueFormatter.php
index 776de0a..bc7a5c4 100644
--- a/src/Reader/XLSX/Helper/CellValueFormatter.php
+++ b/src/Reader/XLSX/Helper/CellValueFormatter.php
@@ -284,9 +284,13 @@ final class CellValueFormatter
\assert(false !== $dateObj);
if ($this->shouldFormatDates) {
- $styleNumberFormatCode = $this->styleManager->getNumberFormatCode($cellStyleId);
- $phpDateFormat = DateFormatHelper::toPHPDateFormat($styleNumberFormatCode);
+ //$styleNumberFormatCode = $this->styleManager->getNumberFormatCode($cellStyleId);
+ //$phpDateFormat = DateFormatHelper::toPHPDateFormat($styleNumberFormatCode);
+ // Toujours utiliser le format français complet
+ $phpDateFormat = "d/m/Y H:i:s";
$cellValue = $dateObj->format($phpDateFormat);
+ // Enlever la composante heure si elle n'existe pas
+ $cellValue = preg_replace('/ 00:00:00$/', "", $cellValue);
} else {
$cellValue = $dateObj;
}
diff --git a/src/Reader/XLSX/Options.php b/src/Reader/XLSX/Options.php
index 636d2a4..e8609b5 100644
--- a/src/Reader/XLSX/Options.php
+++ b/src/Reader/XLSX/Options.php
@@ -10,7 +10,7 @@ final class Options
{
use TempFolderOptionTrait;
- public bool $SHOULD_FORMAT_DATES = false;
+ public bool $SHOULD_FORMAT_DATES = true;
public bool $SHOULD_PRESERVE_EMPTY_ROWS = false;
public bool $SHOULD_USE_1904_DATES = false;
public bool $SHOULD_LOAD_MERGE_CELLS = false;