Box\Spout\Reader\XLSX\Helper\StyleHelper::isFormatCodeMatchingDateFormatPattern PHP Метод

isFormatCodeMatchingDateFormatPattern() защищенный Метод

protected isFormatCodeMatchingDateFormatPattern ( string $formatCode ) : boolean
$formatCode string
Результат boolean Whether the given format code matches a date format pattern
    protected function isFormatCodeMatchingDateFormatPattern($formatCode)
    {
        // Remove extra formatting (what's between [ ], the brackets should not be preceded by a "\")
        $pattern = '((?<!\\\\)\\[.+?(?<!\\\\)\\])';
        $formatCode = preg_replace($pattern, '', $formatCode);
        // custom date formats contain specific characters to represent the date:
        // e - yy - m - d - h - s
        // and all of their variants (yyyy - mm - dd...)
        $dateFormatCharacters = ['e', 'yy', 'm', 'd', 'h', 's'];
        $hasFoundDateFormatCharacter = false;
        foreach ($dateFormatCharacters as $dateFormatCharacter) {
            // character not preceded by "\" (case insensitive)
            $pattern = '/(?<!\\\\)' . $dateFormatCharacter . '/i';
            if (preg_match($pattern, $formatCode)) {
                $hasFoundDateFormatCharacter = true;
                break;
            }
        }
        return $hasFoundDateFormatCharacter;
    }