protected function extractAbbreviation(DateRepresentationInterface $input)
    {
        $offset = $input->getOffset();

        if (null === $abbr = $offset->getAbbreviation()) {
            return $input;
        }

        $abbr = strtolower($abbr);
        $list = DateTimeZone::listAbbreviations();

        if (!isset($list[$abbr]) || empty($list[$abbr])) {
            return $input;
        }

        $list = $list[$abbr];

        $criterias = [
            'offset' => $offset->getValue(),
            'timezone_id' => $input->getTimezone()->getName(),
            'dst' => $offset->isDst(),
        ];

        foreach ($criterias as $key => $value) {
            if (null === $value) {
                continue;
            }
            $previous = $list;

            $list = array_filter($list, function ($infos) use ($key, $value) {
                return $value === $infos[$key];
            });

            if (empty($list)) {
                $list = $previous;
            }
        }

        $infos = reset($list);

        if (null === $offset->getValue()) {
            $offset = $offset->withValue($infos['offset']);
        }

        return $input
            ->withOffset($offset->withDst($infos['dst']))
            ->withTimezone(new DateTimeZone($infos['timezone_id']))
        ;
    }
protected function extractAbbreviation(DateRepresentationInterface $input)
    {
        $offset = $input->getOffset();

        if (null === $abbr = $offset->getAbbreviation()) {
            return $input;
        }

        $abbr = strtolower($abbr);
        $list = DateTimeZone::listAbbreviations();

        if (!isset($list[$abbr]) || empty($list[$abbr])) {
            return $input;
        }

        $list = $list[$abbr];

        $criterias = [
            'offset' => $offset->getValue(),
            'timezone_id' => $input->getTimezone()->getName(),
            'dst' => $offset->isDst(),
        ];

        foreach ($criterias as $key => $value) {
            if (null === $value) {
                continue;
            }
            $previous = $list;

            $list = array_filter($list, function ($infos) use ($key, $value) {
                return $value === $infos[$key];
            });

            if (empty($list)) {
                $list = $previous;
            }
        }

        $infos = reset($list);

        if (null === $offset->getValue()) {
            $offset = $offset->withValue($infos['offset']);
        }

        return $input
            ->withOffset($offset->withDst($infos['dst']))
            ->withTimezone(new DateTimeZone($infos['timezone_id']))
        ;
    }
protected function extractAbbreviation ( DateRepresentationInterface $ input ) { $ offset = $ input -> getOffset ( ) ; if ( null === $ abbr = $ offset -> getAbbreviation ( ) ) { return $ input ; } $ abbr = strtolower ( $ abbr ) ; $ list = DateTimeZone :: listAbbreviations ( ) ; if ( ! isset ( $ list [ $ abbr ] ) || empty ( $ list [ $ abbr ] ) ) { return $ input ; } $ list = $ list [ $ abbr ] ; $ criterias = [ 'offset' => $ offset -> getValue ( ) , 'timezone_id' => $ input -> getTimezone ( ) -> getName ( ) , 'dst' => $ offset -> isDst ( ) , ] ; foreach ( $ criterias as $ key => $ value ) { if ( null === $ value ) { continue ; } $ previous = $ list ; $ list = array_filter ( $ list , function ( $ infos ) use ( $ key , $ value ) { return $ value === $ infos [ $ key ] ; } ) ; if ( empty ( $ list ) ) { $ list = $ previous ; } } $ infos = reset ( $ list ) ; if ( null === $ offset -> getValue ( ) ) { $ offset = $ offset -> withValue ( $ infos [ 'offset' ] ) ; } return $ input -> withOffset ( $ offset -> withDst ( $ infos [ 'dst' ] ) ) -> withTimezone ( new DateTimeZone ( $ infos [ 'timezone_id' ] ) ) ; }
Extract informations from timezone abbreviation.

@param DateRepresentationInterface $input

@return DateRepresentationInterface
Extract informations from timezone abbreviation .