PhpSpreadsheet/tests/data/Shared/Date/FormatCodes.php
oleibman 5dd7e883c6
Fix Issue 1441 (isDateTime and Formulas) (#1480)
* Fix Issue 1441 (isDateTime and Formulas)

When you have a date-field which is a formula, isDateTime returns false.
https://github.com/PHPOffice/PhpSpreadsheet/issues/1441

Report makes sense; fixed as suggested. Also fixed a few minor
related issues, and added tests so that Shared/Date and Shared/TimeZone
are now completely covered.

Date/setDefaultTimeZone and TimeZone/setTimeZone were not consistent
about what to do in event of failure - return false or throw.
They will now both return false, which is what Date's function
said it would do in its doc block anyhow. Date/validateTimeZone will
continue to throw; it was protected, but was never called outside
Date, so I changed it to private.

TimeZone/getTimeZoneAdjustment checked for 'UST' when it probably
meant 'UTC', and, as it turns out, the check is not even needed.

The most serious problem was that TimeZone/validateTimeZone does not
check the backwards-compatible time zones. The timezone project
aggressively, and very controversially, "demotes" timezones;
such timezones eventually wind up in the PHP backwards-compatible list.
We want to make sure to check that list so that our applications do not
break when this happens.
2020-05-24 20:02:39 +02:00

154 lines
1.8 KiB
PHP

<?php
// Excel Format Code Result
return [
[
false,
'General',
],
[
false,
'@',
],
[
false,
'0',
],
[
false,
'0.00',
],
[
false,
'#,##0.00',
],
[
false,
'#,##0.00_-',
],
[
false,
'0%',
],
[
false,
'0.00%',
],
[
true,
'yyyy-mm-dd',
],
[
true,
'yy-mm-dd',
],
[
true,
'dd/mm/yy',
],
[
true,
'd/m/y',
],
[
true,
'd-m-y',
],
[
true,
'd-m',
],
[
true,
'm-y',
],
[
true,
'mm-dd-yy',
],
[
true,
'd-mmm-yy',
],
[
true,
'd-mmm',
],
[
true,
'mmm-yy',
],
[
true,
'm/d/yy h:mm',
],
[
true,
'd/m/y h:mm',
],
[
true,
'h:mm AM/PM',
],
[
true,
'h:mm:ss AM/PM',
],
[
true,
'h:mm',
],
[
true,
'h:mm:ss',
],
[
true,
'mm:ss',
],
[
true,
'h:mm:ss',
],
[
true,
'i:s.S',
],
[
true,
'h:mm:ss;@',
],
[
true,
'yy/mm/dd;@',
],
[
false,
'"$" #,##0.00_-',
],
[
false,
'$#,##0_-',
],
[
false,
'[$EUR ]#,##0.00_-',
],
[
false,
'_[$EUR ]#,##0.00_-',
],
[
false,
'[Green]#,##0.00;[Red]#,##0.00_-',
],
[
false,
'#,##0.00 "dollars"',
],
[
true,
'"date " y-m-d',
],
];