Horde_Icalendar::_parseTZID PHP Метод

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

Groks the TZID and returns an offset in seconds from UTC for this date and time.
protected _parseTZID ( array $date, array $time, string $tzid ) : integer
$date array A date hash.
$time array A time hash.
$tzid string A timezone ID.
Результат integer The offset from UTC in seconds for the provided timezone and date/time.
    protected function _parseTZID($date, $time, $tzid)
    {
        $vtimezone = $this->_container->findComponentByAttribute('vtimezone', 'TZID', $tzid);
        if (!$vtimezone) {
            return false;
        }
        $change_times = array();
        foreach ($vtimezone->getComponents() as $o) {
            $change_times = array_merge($change_times, $vtimezone->parseChild($o, $date['year']));
        }
        if (!$change_times) {
            return false;
        }
        usort($change_times, function ($a, $b) {
            if (!$a['end']) {
                if (!$b['end']) {
                    return $a['time'] - $b['time'];
                }
                return 1;
            }
            if (!$b['end']) {
                return -1;
            }
            return $a['end'] - $b['end'];
        });
        // Time is arbitrarily based on UTC for comparison.
        $t = @gmmktime($time['hour'], $time['minute'], $time['second'], $date['month'], $date['mday'], $date['year']);
        if ($t < $change_times[0]['time']) {
            return $change_times[0]['from'];
        }
        for ($i = 0, $n = count($change_times); $i < $n - 1; $i++) {
            // See Bug: 14153. Some timezone definitions may be such that a
            // transition will incorrectly match due to the way we parse the
            // 'end' times. There *may* be a more correct way to do this by
            // sorting the transitions/handling 'end' values differently.
            if ($t >= $change_times[$i]['time'] && $t < $change_times[$i + 1]['time'] && $this->_checkEndDate($t, $change_times[$i + 1])) {
                return $change_times[$i]['to'];
            }
        }
        if ($t >= $change_times[$n - 1]['time']) {
            return $change_times[$n - 1]['to'];
        }
        return false;
    }