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;
    }
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;
    }
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 ; }
Creates one parsed datetime format from date and time formats merged
together.

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.

@param string $format DateTime format
@param Locale $locale Locale to use
@param string $formatLength A length of format (full, long, medium, short) or 'default' to use default one from CLDR
@return array Merged formats of date and time
Creates one parsed datetime format from date and time formats merged together .