/**
* Calculates a date from the date columns of a Zone line.
*
* @param integer $line A line number.
*
* @return Horde_Date The date of this line.
*/
protected function _getDate($line)
{
$date = array_slice($this->_info[$line], 3);
$year = $date[0];
$month = isset($date[1]) ? Horde_Timezone::getMonth($date[1]) : 1;
$day = isset($date[2]) ? $date[2] : 1;
$time = isset($date[3]) && $date[3] != '-' ? $date[3] : 0;
preg_match('/(\\d+)(?::(\\d+))?(?::(\\d+))?(w|s|u)?/', $time, $match);
if (!isset($match[2])) {
$match[2] = 0;
}
if (!isset($match[3])) {
$match[3] = 0;
}
switch (substr($time, -1)) {
case 's':
// Standard time. Not sure what to do about this.
break;
case 'u':
// UTC, add offset.
$offset = $this->_getOffset($line);
$factor = $offset['ahead'] ? 1 : -1;
$match[1] += $factor * $offset['hour'];
$match[2] += $factor * $offset['minute'];
case 'w':
default:
// Wall time, nothing to do.
break;
}
return new Horde_Date(array('year' => $year, 'month' => $month, 'mday' => $day, 'hour' => $match[1], 'min' => $match[2], 'sec' => $match[3]));
}