formatAsDate strip language metadata (#1618)

* Revert "Fix cant get right format chinese date format error"

This reverts commit 8c58385d6c.

* formatAsDate strip language metadata (fixes #1616)

Co-authored-by: Mark Baker <mark@lange.demon.co.uk>
This commit is contained in:
SheetJSDev 2021-01-29 11:14:38 -05:00 committed by GitHub
parent 8d2d78334f
commit 24fb8e61ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 17 deletions

View File

@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Changed ### Changed
- Updated the CONVERT() function to support all current MS Excel categories and Units of Measure. - Updated the CONVERT() function to support all current MS Excel categories and Units of Measure.
- `formatAsDate` correctly matches language metadata, reverting c55272e
### Deprecated ### Deprecated

View File

@ -469,7 +469,7 @@ class NumberFormat extends Supervisor
// 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('/^(\[[0-9A-Za-z]*\])*(\[\$[A-Z]*-[0-9A-F]*\])/i', '', $format); $format = 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

View File

@ -36,22 +36,6 @@ return [
22269.0625, 22269.0625,
'"y-m-d "yyyy-mm-dd" h:m:s "hh:mm:ss', '"y-m-d "yyyy-mm-dd" h:m:s "hh:mm:ss',
], ],
// Chinese date format
[
'1960年12月19日',
22269.0625,
'[DBNum1][$-804]yyyy"年"m"月"d"日";@',
],
[
'1960年12月',
22269.0625,
'[DBNum1][$-804]yyyy"年"m"月";@',
],
[
'12月19日',
22269.0625,
'[DBNum1][$-804]m"月"d"日";@',
],
[ [
'07:35:00 AM', '07:35:00 AM',
43270.315972222, 43270.315972222,
@ -77,4 +61,15 @@ return [
1.1354166666667, 1.1354166666667,
'[h]:mm', '[h]:mm',
], ],
[
'19331018',
12345.6789,
'[DBNum4][$-804]yyyymmdd;@',
],
// Technically should be
[
'19331018',
12345.6789,
'[DBNum3][$-zh-CN]yyyymmdd;@',
],
]; ];