/** * Returns the calculated date * * @param string $calc Calculation to make * @param string|integer|Zend_Date $date Date to calculate with, if null the actual date is taken * @param string $format Dateformat for parsing * @param string|Zend_Locale $locale Locale for parsing input * @return integer|Zend_Date new date * @throws Zend_Date_Exception */ private function _date($calc, $date, $format, $locale) { if (is_null($date)) { throw new Zend_Date_Exception('parameter $date must be set, null is not allowed'); } if ($locale === null) { $locale = $this->getLocale(); } if ($calc == 'set' or $calc == 'cmp') { $gmt = $this->setGmt(false); } else { $gmt = $this->setGmt(true); } if ($date instanceof Zend_Date) { // extract date from object $date = $date->get(Zend_Date::DATE_MEDIUM, $locale); } else { $parsed = Zend_Locale_Format::getDate($date, $format, $locale); $date = new Zend_Date(0, Zend_Date::TIMESTAMP, $locale); $date->setGmt(true); $date->set($parsed['year'], Zend_Date::YEAR); $date->set($parsed['month'], Zend_Date::MONTH_SHORT); $date->set($parsed['day'], Zend_Date::DAY); $date = $date->get(Zend_Date::DATE_MEDIUM, $locale); } $return = $this->_calcdetail($calc, $date, Zend_Date::DATE_MEDIUM, $locale); $this->setGmt($gmt); if ($calc != 'cmp') { return $this; } return $return; }