/** * Returns the calculated time * * @param string $calc Calculation to make * @param string|integer|array|IfwPsn_Vendor_Zend_Date $time Time to calculate with, if null the actual time is taken * @param string $format Timeformat for parsing input * @param string|IfwPsn_Vendor_Zend_Locale $locale Locale for parsing input * @return integer|IfwPsn_Vendor_Zend_Date new time * @throws IfwPsn_Vendor_Zend_Date_Exception */ private function _time($calc, $time, $format, $locale) { if ($time === null) { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Date/Exception.php'; throw new IfwPsn_Vendor_Zend_Date_Exception('parameter $time must be set, null is not allowed'); } if ($time instanceof IfwPsn_Vendor_Zend_Date) { // extract time from object $time = $time->toString('HH:mm:ss', 'iso'); } else { if (is_array($time)) { if (isset($time['hour']) === true or isset($time['minute']) === true or isset($time['second']) === true) { $parsed = $time; } else { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Date/Exception.php'; throw new IfwPsn_Vendor_Zend_Date_Exception("no hour, minute or second given in array"); } } else { if (self::$_options['format_type'] == 'php') { $format = IfwPsn_Vendor_Zend_Locale_Format::convertPhpToIsoFormat($format); } try { if ($locale === null) { $locale = $this->getLocale(); } $parsed = IfwPsn_Vendor_Zend_Locale_Format::getTime($time, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso')); } catch (IfwPsn_Vendor_Zend_Locale_Exception $e) { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Date/Exception.php'; throw new IfwPsn_Vendor_Zend_Date_Exception($e->getMessage(), 0, $e); } } if (!array_key_exists('hour', $parsed)) { $parsed['hour'] = 0; } if (!array_key_exists('minute', $parsed)) { $parsed['minute'] = 0; } if (!array_key_exists('second', $parsed)) { $parsed['second'] = 0; } $time = str_pad($parsed['hour'], 2, '0', STR_PAD_LEFT) . ":"; $time .= str_pad($parsed['minute'], 2, '0', STR_PAD_LEFT) . ":"; $time .= str_pad($parsed['second'], 2, '0', STR_PAD_LEFT); } $return = $this->_calcdetail($calc, $time, self::TIMES, 'de'); if ($calc != 'cmp') { return $this; } return $return; }
/** * Defined by IfwPsn_Vendor_Zend_Filter_Interface * * Normalizes the given input * * @param string $value Value to normalized * @return string|array The normalized value */ public function filter($value) { if (IfwPsn_Vendor_Zend_Locale_Format::isNumber($value, $this->_options)) { return IfwPsn_Vendor_Zend_Locale_Format::getNumber($value, $this->_options); } else { if ($this->_options['date_format'] === null && strpos($value, ':') !== false) { // Special case, no date format specified, detect time input return IfwPsn_Vendor_Zend_Locale_Format::getTime($value, $this->_options); } else { if (IfwPsn_Vendor_Zend_Locale_Format::checkDateFormat($value, $this->_options)) { // Detect date or time input return IfwPsn_Vendor_Zend_Locale_Format::getDate($value, $this->_options); } } } return $value; }