mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-25 10:18:21 +00:00
241e82b284
See issue #2331. Timestamp is expected in format yyyy-mm-dd (plus other information), with the expectation that month and day are 2 digits zero-filled on the left if needed. The user's file instead used a space rather than zero as filler. Although I don't know how the unexpected timestamp was created, it was easy enough to alter the timestamp in an otherwise normal spreadsheet, and use that file as a test case.
27 lines
985 B
PHP
27 lines
985 B
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
|
|
|
use DateTimeZone;
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class Issue2331Test extends TestCase
|
|
{
|
|
public function testIssue2331(): void
|
|
{
|
|
// Leading space instead of 0 in month and/or day of timestamp.
|
|
$filename = 'tests/data/Reader/XLSX/issue.2331c.xlsx';
|
|
$reader = IOFactory::createReader('Xlsx');
|
|
$spreadsheet = $reader->load($filename);
|
|
$properties = $spreadsheet->getProperties();
|
|
$created = (string) $properties->getCreated();
|
|
$modified = (string) $properties->getModified();
|
|
|
|
self::assertEquals('2021-08-02', Date::formattedDateTimeFromTimestamp($created, 'Y-m-d', new DateTimeZone('UTC')));
|
|
self::assertEquals('2021-09-03', Date::formattedDateTimeFromTimestamp($modified, 'Y-m-d', new DateTimeZone('UTC')));
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
}
|