Skip to content

Commit 079dc87

Browse files
committed
More Tweaks
1 parent c16eaeb commit 079dc87

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/PhpSpreadsheet/Shared/Date.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,7 @@ public static function convertIsoDate(mixed $value): float|int
172172
throw new Exception("Invalid string $value supplied for datatype Date");
173173
}
174174

175-
$newValue = self::PHPToExcel($date);
176-
if ($newValue === false) {
177-
throw new Exception("Invalid string $value supplied for datatype Date");
178-
}
175+
$newValue = self::dateTimeToExcel($date);
179176

180177
if (preg_match('/^\s*\d?\d:\d\d(:\d\d([.]\d+)?)?\s*(am|pm)?\s*$/i', $value) == 1) {
181178
$newValue = fmod($newValue, 1.0);

tests/PhpSpreadsheetTests/Shared/DateTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ public function testVarious(): void
204204

205205
$date = Date::PHPToExcel('2020-01-01');
206206
self::assertEquals(43831.0, $date);
207+
$phpDate = new DateTime('2020-01-02T00:00Z');
208+
$date = Date::PHPToExcel($phpDate);
209+
self::assertEquals(43832.0, $date);
207210

208211
$spreadsheet = new Spreadsheet();
209212
$sheet = $spreadsheet->getActiveSheet();

0 commit comments

Comments
 (0)