Remove text suffix in XLSX date formats (#341)

Some date formats have a text suffix, e.g. "mm/dd/yy;@". We should remove the ";...@" part.
This commit is contained in:
Adrien Loison authored and GitHub committed 2016-10-18 11:55:36 -07:00
1 parent 687c321363
commit 73d5d0ea17
2 files changed
+5 -1

No files matched your search

@@ -62,7 +62,9 @@ class DateFormatHelper
public static function toPHPDateFormat($excelDateFormat)
{
// Remove brackets potentially present at the beginning of the format string
$dateFormat = preg_replace('/^(\[\$[^\]]+?\])/i', '', $excelDateFormat);
// and text portion of the format at the end of it (starting with ";")
// See §18.8.31 of ECMA-376 for more detail.
$dateFormat = preg_replace('/^(?:\[\$[^\]]+?\])?([^;]*).*/', '$1', $excelDateFormat);
// Double quotes are used to escape characters that must not be interpreted.
// For instance, ["Day " dd] should result in "Day 13" and we should not try to interpret "D", "a", "y"