Corrected date time detection (#1492)

* Corrected date time detection

German and Swiss ZIP codes (special formats provided in German Excel versions) were detected as date time value, because the regular expression for date time formats falsely matched their formats ("\C\H\-00000" and "\D-00000").
This commit is contained in:
Christoph Ziegenberg 2020-06-20 17:15:38 +02:00 committed by GitHub
parent acd2ba01df
commit ca506ba87f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -387,6 +387,11 @@ class Date
if ((substr($pFormatCode, 0, 1) == '_') || (substr($pFormatCode, 0, 2) == '0 ')) {
return false;
}
// Some "special formats" provided in German Excel versions were detected as date time value,
// so filter them out here - "\C\H\-00000" (Switzerland) and "\D-00000" (Germany).
if (\strpos($pFormatCode, '-00000') !== false) {
return false;
}
// Try checking for any of the date formatting characters that don't appear within square braces
if (preg_match('/(^|\])[^\[]*[' . self::$possibleDateFormatCharacters . ']/i', $pFormatCode)) {
// We might also have a format mask containing quoted strings...

View File

@ -150,4 +150,12 @@ return [
true,
'"date " y-m-d',
],
[
false,
'\C\H\-00000',
],
[
false,
'\D-00000',
],
];