'', 'i' => '', 'a' => ''], ['g' => '', 'i' => '', 'a' => '']], ...] - array time pairs according to format * - ['H:i:s', 'H:i:s'], ...] - [StartTime, EndTime] string time pairs * @param mixed $value * @return void|Zend_Form_Element */ public function setValue($value) { $this->_value = array(); foreach ((array) $value as $row) { list($start, $end) = $row; if (is_array($start) || is_array($end)) { $this->_value[] = array( $this->_extractTime($start), $this->_extractTime($end), ); } else { $this->_value[] = array( ($dt = DateTime::createFromFormat(self::TIME_FORMAT, $start)) ? $dt->format(self::TIME_FORMAT) : null, ($dt = DateTime::createFromFormat(self::TIME_FORMAT, $end)) ? $dt->format(self::TIME_FORMAT) : null, ); } } return $this; } protected function _filterValue(&$value, &$key) { if (is_array($value)) { $value = $this->_extractTime($value); } foreach ($this->getFilters() as $filter) { $value = $filter->filter($value); } } /** * Converts array with time parts to string * @param array $time Array containing time parts according to format ['g' => '', 'i' => '', 'a' => ''] * @return string */ protected function _extractTime(array $time) { $result = ''; $format = $this->getFormat(); for ($i = 0, $length = strlen($format); $i < $length; ++$i) { $char = $format[$i]; $code = ord($char); $result .= (65 <= $code && $code <= 122) ? $time[$char] : $char; } return ($dt = DateTime::createFromFormat($format, $result)) ? $dt->format(self::TIME_FORMAT) : null; } public function loadDefaultDecorators() { if (!$this->loadDefaultDecoratorsIsDisabled()) { parent::loadDefaultDecorators(); $this->addDecorator('TimeRanges'); } return $this; } public function setRequired($flag = true) { $this->_required = (bool) $flag; $this->required = $this->_required; return $this; } public function setFormat($format) { $this->format = $format; return $this; } public function getFormat() { return $this->format; } public function setCount($count) { $this->count = abs((int) $count); return $this; } public function getCount() { return $this->count; } }