Neos\Flow\I18n\Cldr\Reader\DatesReader::prepareDateAndTimeFormat PHP Method

prepareDateAndTimeFormat() protected method

The dateTime format from CLDR looks like "{0} {1}" and denotes where to place time and date, and what literals should be placed before, between and / or after them.
protected prepareDateAndTimeFormat ( string $format, Locale $locale, string $formatLength ) : array
$format string DateTime format
$locale Neos\Flow\I18n\Locale Locale to use
$formatLength string A length of format (full, long, medium, short) or 'default' to use default one from CLDR
return array Merged formats of date and time
    protected function prepareDateAndTimeFormat($format, Locale $locale, $formatLength)
    {
        $parsedFormatForDate = $this->parseFormatFromCldr($locale, 'date', $formatLength);
        $parsedFormatForTime = $this->parseFormatFromCldr($locale, 'time', $formatLength);
        $positionOfTimePlaceholder = strpos($format, '{0}');
        $positionOfDatePlaceholder = strpos($format, '{1}');
        if ($positionOfTimePlaceholder < $positionOfDatePlaceholder) {
            $positionOfFirstPlaceholder = $positionOfTimePlaceholder;
            $positionOfSecondPlaceholder = $positionOfDatePlaceholder;
            $firstParsedFormat = $parsedFormatForTime;
            $secondParsedFormat = $parsedFormatForDate;
        } else {
            $positionOfFirstPlaceholder = $positionOfDatePlaceholder;
            $positionOfSecondPlaceholder = $positionOfTimePlaceholder;
            $firstParsedFormat = $parsedFormatForDate;
            $secondParsedFormat = $parsedFormatForTime;
        }
        $parsedFormat = [];
        if ($positionOfFirstPlaceholder !== 0) {
            // Add everything before placeholder as literal
            $parsedFormat[] = [substr($format, 0, $positionOfFirstPlaceholder)];
        }
        $parsedFormat = array_merge($parsedFormat, $firstParsedFormat);
        if ($positionOfSecondPlaceholder - $positionOfFirstPlaceholder > 3) {
            // There is something between the placeholders
            $parsedFormat[] = [substr($format, $positionOfFirstPlaceholder + 3, $positionOfSecondPlaceholder - ($positionOfFirstPlaceholder + 3))];
        }
        $parsedFormat = array_merge($parsedFormat, $secondParsedFormat);
        if ($positionOfSecondPlaceholder !== strlen($format) - 1) {
            // Add everything before placeholder as literal
            $parsedFormat[] = [substr($format, $positionOfSecondPlaceholder + 3)];
        }
        return $parsedFormat;
    }