parent
7fe5ee84ea
commit
c286fb8957
|
|
@ -123,12 +123,12 @@ class DateFormatter
|
||||||
// general syntax: [$<Currency string>-<language info>]
|
// general syntax: [$<Currency string>-<language info>]
|
||||||
// language info is in hexadecimal
|
// language info is in hexadecimal
|
||||||
// strip off chinese part like [DBNum1][$-804]
|
// strip off chinese part like [DBNum1][$-804]
|
||||||
$format = preg_replace('/^(\[DBNum\d\])*(\[\$[^\]]*\])/i', '', $format) ?? '';
|
$format = (string) preg_replace('/^(\[DBNum\d\])*(\[\$[^\]]*\])/i', '', $format);
|
||||||
|
|
||||||
// OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case;
|
// OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case;
|
||||||
// but we don't want to change any quoted strings
|
// but we don't want to change any quoted strings
|
||||||
/** @var callable */
|
/** @var callable */
|
||||||
$callable = ['self', 'setLowercaseCallback'];
|
$callable = [self::class, 'setLowercaseCallback'];
|
||||||
$format = preg_replace_callback('/(?:^|")([^"]*)(?:$|")/', $callable, $format);
|
$format = preg_replace_callback('/(?:^|")([^"]*)(?:$|")/', $callable, $format);
|
||||||
|
|
||||||
// Only process the non-quoted blocks for date format characters
|
// Only process the non-quoted blocks for date format characters
|
||||||
|
|
@ -159,14 +159,14 @@ class DateFormatter
|
||||||
|
|
||||||
// escape any quoted characters so that DateTime format() will render them correctly
|
// escape any quoted characters so that DateTime format() will render them correctly
|
||||||
/** @var callable */
|
/** @var callable */
|
||||||
$callback = ['self', 'escapeQuotesCallback'];
|
$callback = [self::class, 'escapeQuotesCallback'];
|
||||||
$format = preg_replace_callback('/"(.*)"/U', $callback, $format) ?? '';
|
$format = (string) preg_replace_callback('/"(.*)"/U', $callback, $format);
|
||||||
|
|
||||||
$dateObj = Date::excelToDateTimeObject($value);
|
$dateObj = Date::excelToDateTimeObject($value);
|
||||||
// If the colon preceding minute had been quoted, as happens in
|
// If the colon preceding minute had been quoted, as happens in
|
||||||
// Excel 2003 XML formats, m will not have been changed to i above.
|
// Excel 2003 XML formats, m will not have been changed to i above.
|
||||||
// Change it now.
|
// Change it now.
|
||||||
$format = \preg_replace('/\\\\:m/', ':i', $format) ?? '';
|
$format = (string) \preg_replace('/\\\\:m/', ':i', $format);
|
||||||
|
|
||||||
return $dateObj->format($format);
|
return $dateObj->format($format);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue