Fix cant get right format chinese date format error

modify preg expression in NumberFormat.php

[DBNum1][$-804]yyyy"年"m"月"d"日";@
[DBNum1][$-804]yyyy"年"m"月";@
[DBNum1][$-804]m"月"d"日";@

FIX #44
This commit is contained in:
Green Wang 2016-11-21 11:56:10 +08:00 committed by Adrien Crivelli
parent 939f24ecb4
commit 8c58385d6c
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
2 changed files with 18 additions and 1 deletions

View File

@ -464,7 +464,8 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp
// strip off first part containing e.g. [$-F800] or [$USD-409] // strip off first part containing e.g. [$-F800] or [$USD-409]
// general syntax: [$<Currency string>-<language info>] // general syntax: [$<Currency string>-<language info>]
// language info is in hexadecimal // language info is in hexadecimal
$format = preg_replace('/^(\[\$[A-Z]*-[0-9A-F]*\])/i', '', $format); // strip off chinese part like [DBNum1][$-804]
$format = preg_replace('/^(\[[0-9A-Za-z]*\])*(\[\$[A-Z]*-[0-9A-F]*\])/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

View File

@ -36,4 +36,20 @@ return [
'"y-m-d "yyyy-mm-dd" h:m:s "hh:mm:ss', '"y-m-d "yyyy-mm-dd" h:m:s "hh:mm:ss',
'y-m-d 1960-12-19 h:m:s 01:30:00', 'y-m-d 1960-12-19 h:m:s 01:30:00',
], ],
// Chinese date format
[
22269.0625,
'[DBNum1][$-804]yyyy"年"m"月"d"日";@',
'1960年12月19日',
],
[
22269.0625,
'[DBNum1][$-804]yyyy"年"m"月";@',
'1960年12月',
],
[
22269.0625,
'[DBNum1][$-804]m"月"d"日";@',
'12月19日',
],
]; ];