/** * Grok the TZID and return an offset in seconds from UTC for this * date and time. */ function _parseTZID($date, $time, $tzid) { $vtimezone = $this->_container->findComponentByAttribute('vtimezone', 'TZID', $tzid); if (!$vtimezone) { return false; } $change_times = array(); foreach ($vtimezone->getComponents() as $o) { $t = $vtimezone->parseChild($o, $date['year']); if ($t !== false) { $change_times[] = $t; } } if (!$change_times) { return false; } sort($change_times); // 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++) { if ($t >= $change_times[$i]['time'] && $t < $change_times[$i + 1]['time']) { return $change_times[$i]['to']; } } if ($t >= $change_times[$n - 1]['time']) { return $change_times[$n - 1]['to']; } return false; }