PhpSpreadsheet/tests/data/Style/NumberFormatDates.php
Derek Bonner 01501b6ff2 Remove locale from format string to prevent formatting error (#644)
When a formatting string has a locale in it an error can occur when outputting. For example when the format string with a locale such as `[$-1010409]#,##0.00;-#,##0.00` appears, a value of 9.98 comes back as $9.98. This is because at https://github.com/PHPOffice/PhpSpreadsheet/blob/1.4.0/src/PhpSpreadsheet/Style/NumberFormat.php#L711 the numberFormat regex will match to the zeros inside the locale ([$-1010409]). Attempts to adjust the numberFormat regex caused regressions in other tests. Adding another step to filter out the locale caused no regression.
2018-09-28 21:28:40 +09:00

76 lines
1.5 KiB
PHP

<?php
return [
[
'19-12-1960 01:30:00',
22269.0625,
'dd-mm-yyyy hh:mm:ss',
],
// Oasis uses upper-case
[
'12/19/1960 01:30:00',
22269.0625,
'MM/DD/YYYY HH:MM:SS',
],
// Date with plaintext escaped with a \
[
'1960-12-19T01:30:00',
22269.0625,
'yyyy-mm-dd\\Thh:mm:ss',
],
// Date with plaintext in quotes
[
'1960-12-19T01:30:00 Z',
22269.0625,
'yyyy-mm-dd"T"hh:mm:ss \\Z',
],
// Date with quoted formatting characters
[
'y-m-d 1960-12-19 h:m:s 01:30:00',
22269.0625,
'"y-m-d" yyyy-mm-dd "h:m:s" hh:mm:ss',
],
// Date with quoted formatting characters
[
'y-m-d 1960-12-19 h:m:s 01:30:00',
22269.0625,
'"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',
43270.315972222,
'hh:mm:ss\ AM/PM',
],
[
'02:29:00 PM',
43270.603472222,
'hh:mm:ss\ AM/PM',
],
[
'8/20/2018',
43332,
'[$-409]m/d/yyyy',
],
[
'8/20/2018',
43332,
'[$-1010409]m/d/yyyy',
],
];