Пример #1
0
 /**
  * Returns the calculated time
  *
  * @param  string                    $calc    Calculation to make
  * @param  string|integer|array|Zend_Date  $time    Time to calculate with, if null the actual time is taken
  * @param  string                          $format  Timeformat for parsing input
  * @param  string|Zend_Locale              $locale  Locale for parsing input
  * @return integer|Zend_Date  new time
  * @throws Zend_Date_Exception
  */
 private function _time($calc, $time, $format, $locale)
 {
     if ($time === null) {
         require_once 'Zend/Date/Exception.php';
         throw new Zend_Date_Exception('parameter $time must be set, null is not allowed');
     }
     if ($time instanceof 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 'Zend/Date/Exception.php';
                 throw new Zend_Date_Exception("no hour, minute or second given in array");
             }
         } else {
             if (self::$_options['format_type'] == 'php') {
                 $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
             }
             try {
                 if ($locale === null) {
                     $locale = $this->getLocale();
                 }
                 $parsed = Zend_Locale_Format::getTime($time, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso'));
             } catch (Zend_Locale_Exception $e) {
                 require_once 'Zend/Date/Exception.php';
                 throw new 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;
 }
Пример #2
0
 /**
  * Defined by Zend_Filter_Interface
  *
  * Normalizes the given input
  *
  * @param  string $value Value to normalized
  * @return string|array The normalized value
  */
 public function filter($value)
 {
     if (Zend_Locale_Format::isNumber($value, $this->_options)) {
         return 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 Zend_Locale_Format::getTime($value, $this->_options);
         } else {
             if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) {
                 // Detect date or time input
                 return Zend_Locale_Format::getDate($value, $this->_options);
             }
         }
     }
     return $value;
 }
Пример #3
0
 /**
  * Returns the calculated time
  *
  * @param  string                    $calc    Calculation to make
  * @param  string|integer|array|Zend_Date  $time    Time to calculate with, if null the actual time is taken
  * @param  string                          $format  Timeformat for parsing input
  * @param  string|Zend_Locale              $locale  Locale for parsing input
  * @return integer|Zend_Date  new time
  * @throws Zend_Date_Exception
  */
 private function _time($calc, $time, $format, $locale)
 {
     if (is_null($time)) {
         require_once 'Zend/Date/Exception.php';
         throw new Zend_Date_Exception('parameter $time must be set, null is not allowed');
     }
     if ($locale === null) {
         $locale = $this->getLocale();
     }
     if ($time instanceof Zend_Date) {
         // extract time from object
         $time = $time->get(self::TIME_MEDIUM, $locale);
     } 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 'Zend/Date/Exception.php';
                 throw new Zend_Date_Exception("no hour, minute or second given in array");
             }
         } else {
             if (self::$_options['format_type'] == 'php') {
                 $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
             }
             try {
                 $parsed = Zend_Locale_Format::getTime($time, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso'));
             } catch (Zend_Locale_Exception $e) {
                 require_once 'Zend/Date/Exception.php';
                 throw new Zend_Date_Exception($e->getMessage());
             }
         }
         $time = new self(0, self::TIMESTAMP, $locale);
         $time->setTimezone('UTC');
         $time->set($parsed['hour'], self::HOUR);
         $time->set($parsed['minute'], self::MINUTE);
         $time->set($parsed['second'], self::SECOND);
         $time = $time->get(self::TIME_MEDIUM, $locale);
     }
     $return = $this->_calcdetail($calc, $time, self::TIME_MEDIUM, $locale);
     if ($calc != 'cmp') {
         return $this;
     }
     return $return;
 }
Пример #4
0
     $errors['activityID'] = $kga['lang']['errorMessages']['noActivitySelected'];
 }
 if (!is_numeric($data['projectID'])) {
     $errors['projectID'] = $kga['lang']['errorMessages']['noProjectSelected'];
 }
 if (count($errors) > 0) {
     echo json_encode(array('errors' => $errors));
     return;
 }
 $edit_in_day = Zend_Locale_Format::getDate($_REQUEST['start_day'], array('date_format' => 'dd.MM.yyyy'));
 $edit_in_time = Zend_Locale_Format::getTime($_REQUEST['start_time'], array('date_format' => 'HH:mm:ss'));
 $edit_in = array_merge($edit_in_day, $edit_in_time);
 $inDate = new Zend_Date($edit_in);
 if ($_REQUEST['end_day'] != '' || $_REQUEST['end_time'] != '') {
     $edit_out_day = Zend_Locale_Format::getDate($_REQUEST['end_day'], array('date_format' => 'dd.MM.yyyy'));
     $edit_out_time = Zend_Locale_Format::getTime($_REQUEST['end_time'], array('date_format' => 'HH:mm:ss'));
     $edit_out = array_merge($edit_out_day, $edit_out_time);
     $outDate = new Zend_Date($edit_out);
 } else {
     $outDate = null;
 }
 $data['start'] = $inDate->getTimestamp();
 if ($outDate != null) {
     $data['end'] = $outDate->getTimestamp();
     $data['duration'] = $data['end'] - $data['start'];
 }
 if ($id) {
     // TIME RIGHT - NEW OR EDIT ?
     if (!timesheetAccessAllowed($data, $action, $errors)) {
         echo json_encode(array('errors' => $errors));
         break;
Пример #5
0
    /**
     * test getTime
     * expected array
     */
    public function testgetTime()
    {
        try {
            $value = Zend_Locale_Format::getTime('no content');
            $this->fail("exception expected");
        } catch (Zend_Locale_Exception $e) {
            // success
        }

        $this->assertTrue(is_array(Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss'))));
        $options = array('date_format' => 'h:mm:ss a', 'locale' => 'en');
        $this->assertTrue(is_array(Zend_Locale_Format::getTime('11:14:55 am', $options)));
        $this->assertTrue(is_array(Zend_Locale_Format::getTime('12:14:55 am', $options)));
        $this->assertTrue(is_array(Zend_Locale_Format::getTime('11:14:55 pm', $options)));
        $this->assertTrue(is_array(Zend_Locale_Format::getTime('12:14:55 pm', $options)));

        try {
            $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'nocontent'));
            $this->fail("exception expected");
        } catch (Zend_Locale_Exception $e) {
            // success
        }

        try {
            $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'ZZZZ'));
            $this->fail("exception expected");
        } catch (Zend_Locale_Exception $e) {
            // success
        }

        try {
            $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss.x'));
            $this->fail("exception expected");
        } catch (Zend_Locale_Exception $e) {
            // success
        }

        $this->assertEquals(5, count(Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss'))));

        $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss'));
        $this->assertEquals(13, $value['hour']  );
        $this->assertEquals(14, $value['minute']);
        $this->assertEquals(55, $value['second']);

        $value = Zend_Locale_Format::getTime('131455', array('date_format' => 'HH:mm:ss'));
        $this->assertEquals(13, $value['hour']  );
        $this->assertEquals(14, $value['minute']);
        $this->assertEquals(55, $value['second']);
    }
Пример #6
0
 /**
  * test getTime
  * expected array
  */
 public function testgetTime()
 {
     try {
         $value = Zend_Locale_Format::getTime('no content');
         $this->fail("no time expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     $this->assertEquals(is_array(Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss'))), true, "array expected");
     $options = array('date_format' => 'h:mm:ss a', 'locale' => 'en');
     $this->assertEquals(is_array(Zend_Locale_Format::getTime('11:14:55 am', $options)), true, "array expected");
     $this->assertEquals(is_array(Zend_Locale_Format::getTime('12:14:55 am', $options)), true, "array expected");
     $this->assertEquals(is_array(Zend_Locale_Format::getTime('11:14:55 pm', $options)), true, "array expected");
     $this->assertEquals(is_array(Zend_Locale_Format::getTime('12:14:55 pm', $options)), true, "array expected");
     try {
         $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'nocontent'));
         $this->fail("no time expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     try {
         $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'ZZZZ'));
         $this->fail("no time expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     try {
         $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss.x'));
         $this->fail("no time expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     $this->assertEquals(count(Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss'))), 5, "array with 5 tags expected");
     $value = Zend_Locale_Format::getTime('13:14:55', array('date_format' => 'HH:mm:ss'));
     $this->assertEquals($value['hour'], 13, 'Hour 13 expected');
     $this->assertEquals($value['minute'], 14, 'Minute 14 expected');
     $this->assertEquals($value['second'], 55, 'Second 55 expected');
     $value = Zend_Locale_Format::getTime('131455', array('date_format' => 'HH:mm:ss'));
     $this->assertEquals($value['hour'], 13, 'Hour 13 expected');
     $this->assertEquals($value['minute'], 14, 'Minute 14 expected');
     $this->assertEquals($value['second'], 55, 'Second 55 expected');
 }
Пример #7
0
 /**
  * test if getTime parses a time with fixed format
  * expected array
  */
 public function testgetTimeParsing4()
 {
     $value = Zend_Locale_Format::getTime('131455', 'HH:mm:ss');
     $this->assertEquals($value['hour'], 13, 'Hour 13 expected');
     $this->assertEquals($value['minute'], 14, 'Minute 14 expected');
     $this->assertEquals($value['second'], 55, 'Second 55 expected');
 }
 /**
  * Defined by Zend_Filter_Interface
  *
  * Normalizes the given input
  *
  * @param  string $value Value to normalized
  * @return string|array The normalized value
  */
 public function filter($value)
 {
     if (Zend_Locale_Format::isNumber($value, $this->_options)) {
         return Zend_Locale_Format::getNumber($value, $this->_options);
         //        if (($this->_options['precision'] === 0) && Zend_Locale_Format::isInteger($value, $this->_options)) {
         // Detect integer
         //            return Zend_Locale_Format::getInteger($value, $this->_options);
         //        } else if (($this->_options['precision'] === null) && Zend_Locale_Format::isFloat($value, $this->_options)) {
         // Detect float
         //            return Zend_Locale_Format::getFloat($value, $this->_options);
         //        } else if (Zend_Locale_Format::isNumber($value, $this->_options)) {
         // Detect all other numbers
         //            return 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 Zend_Locale_Format::getTime($value, $this->_options);
         } else {
             if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) {
                 // Detect date or time input
                 return Zend_Locale_Format::getDate($value, $this->_options);
             }
         }
     }
     return $value;
 }
Пример #9
0
 /**
  * Returns the calculated time
  *
  * @param  string                    $calc    Calculation to make
  * @param  string|integer|Zend_Date  $time    Time to calculate with, if null the actual time is taken
  * @param  string                    $format  Timeformat for parsing input
  * @param  string|Zend_Locale        $locale  Locale for parsing input
  * @return integer|Zend_Date  new time
  * @throws Zend_Date_Exception
  */
 private function _time($calc, $time, $format, $locale)
 {
     if (is_null($time)) {
         throw new Zend_Date_Exception('parameter $time must be set, null is not allowed');
     }
     if ($locale === null) {
         $locale = $this->getLocale();
     }
     if ($time instanceof Zend_Date) {
         // extract time from object
         $time = $time->get(Zend_Date::TIME_MEDIUM, $locale);
     } else {
         $parsed = Zend_Locale_Format::getTime($time, $format, $locale);
         $time = new Zend_Date(0, Zend_Date::TIMESTAMP, $locale);
         $time->set($parsed['hour'], Zend_Date::HOUR);
         $time->set($parsed['minute'], Zend_Date::MINUTE);
         $time->set($parsed['second'], Zend_Date::SECOND);
         $time = $time->get(Zend_Date::TIME_MEDIUM, $locale);
     }
     $return = $this->_calcdetail($calc, $time, Zend_Date::TIME_MEDIUM, $locale);
     if ($calc != 'cmp') {
         return $this;
     }
     return $return;
 }
Пример #10
0
 /**
  * Calculates the date or object
  *
  * @param  $calc string  - calculation to make
  * @param  $date string  - date which shall be our new date object
  * @param  $part         - datepart, if empty the timestamp will be returned
  * @param  $locale       - OPTIONAL, locale for output
  * @param  $gmt          - OPTIONAL, TRUE = actual timezone time, FALSE = UTC time
  * @return timestamp
  */
 private function _calculate($calc, $date, $part, $locale = false, $gmt = false)
 {
     if ($locale === false) {
         $locale = $this->_Locale;
     }
     // create date parts
     $year = $this->get(Zend_Date::YEAR);
     $month = $this->get(Zend_Date::MONTH_DIGIT);
     $day = $this->get(Zend_Date::DAY_SHORT);
     $hour = $this->get(Zend_Date::HOUR_SHORT);
     $minute = $this->get(Zend_Date::MINUTE_SHORT);
     $second = $this->get(Zend_Date::SECOND_SHORT);
     // if object extract value
     if (is_object($date)) {
         $date = $date->get($part, $locale, $gmt);
     }
     // $date as object, part of foreign date as own date
     switch ($part) {
         // day formats
         case Zend_Date::DAY:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, intval($date), 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, intval($day), 0, -1, $gmt));
             break;
         case Zend_Date::WEEKDAY_SHORT:
             $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'wide'));
             $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale, $gmt);
             $cnt = 0;
             foreach ($daylist as $key => $value) {
                 if (strtoupper(substr($value, 0, 3)) == strtoupper($date)) {
                     $found = $cnt + 1;
                     break;
                 }
                 ++$cnt;
             }
             // Weekday found
             if ($cnt < 7) {
                 return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, $found, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, $weekday, 0, -1, $gmt));
             }
             // Weekday not found
             return false;
             break;
         case Zend_Date::DAY_SHORT:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, intval($date), 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, intval($day), 0, -1, $gmt));
             break;
         case Zend_Date::WEEKDAY:
             $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'wide'));
             $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale, $gmt);
             $cnt = 0;
             foreach ($daylist as $key => $value) {
                 if (strtoupper($value) == strtoupper($date)) {
                     $found = $cnt + 1;
                     break;
                 }
                 ++$cnt;
             }
             // Weekday found
             if ($cnt < 7) {
                 return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, $found, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, $weekday, 0, -1, $gmt));
             }
             // Weekday not found
             return false;
             break;
         case Zend_Date::WEEKDAY_8601:
             $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale, $gmt);
             if (intval($date) > 0 and intval($date) < 8) {
                 return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, intval($date), 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, $weekday, 0, -1, $gmt));
             }
             // Weekday not found
             return false;
             break;
         case Zend_Date::DAY_SUFFIX:
             return false;
             break;
         case Zend_Date::WEEKDAY_DIGIT:
             $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale, $gmt);
             if (intval($date) > 0 and intval($date) < 8) {
                 return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, $date + 1, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, $weekday, 0, -1, $gmt));
             }
             // Weekday not found
             return false;
             break;
         case Zend_Date::DAY_OF_YEAR:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, $date, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, $month, $day, 0, -1, $gmt));
             break;
         case Zend_Date::WEEKDAY_NARROW:
             $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'abbreviated'));
             $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale, $gmt);
             $cnt = 0;
             foreach ($daylist as $key => $value) {
                 if (strtoupper(substr($value, 0, 1)) == strtoupper($date)) {
                     $found = $cnt + 1;
                     break;
                 }
                 ++$cnt;
             }
             // Weekday found
             if ($cnt < 7) {
                 return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, $found, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, $weekday, 0, -1, $gmt));
             }
             // Weekday not found
             return false;
             break;
         case Zend_Date::WEEKDAY_NAME:
             $daylist = Zend_Locale_Data::getContent($locale, 'daylist', array('gregorian', 'abbreviated'));
             $weekday = (int) $this->get(Zend_Date::WEEKDAY_DIGIT, $locale, $gmt);
             $cnt = 0;
             foreach ($daylist as $key => $value) {
                 if (strtoupper($value) == strtoupper($date)) {
                     $found = $cnt + 1;
                     break;
                 }
                 ++$cnt;
             }
             // Weekday found
             if ($cnt < 7) {
                 return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, $found, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, $weekday, 0, -1, $gmt));
             }
             // Weekday not found
             return false;
             break;
             // week formats
         // week formats
         case Zend_Date::WEEK:
             $week = (int) $this->get(Zend_Date::WEEK, $locale, $gmt);
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, $week * 7, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, $date * 7, 0, -1, $gmt));
             break;
             // month formats
         // month formats
         case Zend_Date::MONTH:
             $monthlist = Zend_Locale_Data::getContent($locale, 'monthlist', array('gregorian', 'wide'));
             $monthnr = (int) $this->get(Zend_Date::MONTH_DIGIT, $locale, $gmt) - 1;
             $cnt = 0;
             foreach ($monthlist as $key => $value) {
                 if (strtoupper($value) == strtoupper($date)) {
                     $found = $cnt + 1;
                     break;
                 }
                 ++$cnt;
             }
             // Monthname found
             if ($cnt < 12) {
                 return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, $found, 1, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, $monthnr, 1, 0, -1, $gmt));
             }
             // Monthname not found
             return false;
             break;
         case Zend_Date::MONTH_SHORT:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, intval($date), 1, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, $month, 1, 0, -1, $gmt));
             break;
         case Zend_Date::MONTH_NAME:
             $monthlist = Zend_Locale_Data::getContent($locale, 'monthlist', array('gregorian', 'abbreviated'));
             $monthnr = (int) $this->get(Zend_Date::MONTH_DIGIT, $locale, $gmt) - 1;
             $cnt = 0;
             foreach ($monthlist as $key => $value) {
                 if (strtoupper($value) == strtoupper($date)) {
                     $found = $cnt + 1;
                     break;
                 }
                 ++$cnt;
             }
             // Monthname found
             if ($cnt < 12) {
                 return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, $found, 1, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, $monthnr, 1, 0, -1, $gmt));
             }
             // Monthname not found
             return false;
             break;
         case Zend_Date::MONTH_DIGIT:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, intval($date), 1, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, $month, 1, 0, -1, $gmt));
             break;
         case Zend_Date::MONTH_DAYS:
             return false;
             break;
         case Zend_Date::MONTH_NARROW:
             $monthlist = Zend_Locale_Data::getContent($locale, 'monthlist', array('gregorian', 'abbreviated'));
             $monthnr = (int) $this->get(Zend_Date::MONTH_DIGIT, $locale, $gmt) - 1;
             $cnt = 0;
             foreach ($monthlist as $key => $value) {
                 if (strtoupper(substr($value, 0, 1)) == strtoupper(substr($date, 0, 1))) {
                     $found = $cnt + 1;
                     break;
                 }
                 ++$cnt;
             }
             // Monthname found
             if ($cnt < 12) {
                 return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, $found, 1, 0, -1, $gmt), $this->_Date->mktime(0, 0, 0, $monthnr, 1, 0, -1, $gmt));
             }
             // Monthname not found
             return false;
             break;
             // year formats
         // year formats
         case Zend_Date::LEAPYEAR:
             return false;
             break;
         case Zend_Date::YEAR_8601:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, 1, intval($date), -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, 1, $year, -1, $gmt));
             break;
         case Zend_Date::YEAR:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, 1, intval($date), -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, 1, $year, -1, $gmt));
             break;
         case Zend_Date::YEAR_SHORT:
             $date = intval($date);
             if ($date > 0 and $date < 100) {
                 $date += 1900;
                 if ($date < 70) {
                     $date += 100;
                 }
             }
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, 1, $date, -1, $gmt), $this->_Date->mktime(0, 0, 0, 1, 1, $year, -1, $gmt));
             break;
         case Zend_Date::YEAR_SHORT_8601:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, 1, 1, intval($date), -1, $gmt));
             break;
             // time formats
         // time formats
         case Zend_Date::MERIDIEM:
             $meridiemlist = Zend_Locale_Data::getContent($locale, 'daytime', 'gregorian');
             $meridiem = strtoupper($this->get(Zend_Date::MERIDIEM, $locale, $gmt));
             if ($meridiem == strtoupper($meridiemlist['am']) && strtoupper($date) == strtoupper($meridiemlist['pm'])) {
                 $date = 12;
             } else {
                 if ($meridiem == strtoupper($meridiemlist['pm']) && strtoupper($date) == strtoupper($meridiemlist['am'])) {
                     $date = -12;
                 }
             }
             if ($hour > 12) {
                 $hour = -12;
             }
             return $this->_assign($calc, $this->_Date->mktime($date, 0, 0, 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, 0, 0, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::SWATCH:
             $rest = intval($date);
             $hours = floor($rest / 3600);
             $rest = $rest - $hours * 3600;
             $minutes = floor($rest / 60);
             $seconds = $rest - $minutes * 60;
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::HOUR_SHORT_AM:
             return $this->_assign($calc, $this->_Date->mktime(intval($date), 0, 0, 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, 0, 0, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::HOUR_SHORT:
             return $this->_assign($calc, $this->_Date->mktime(intval($date), 0, 0, 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, 0, 0, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::HOUR_AM:
             return $this->_assign($calc, $this->_Date->mktime(intval($date), 0, 0, 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, 0, 0, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::HOUR:
             return $this->_assign($calc, $this->_Date->mktime(intval($date), 0, 0, 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, 0, 0, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::MINUTE:
             return $this->_assign($calc, $this->_Date->mktime(0, intval($date), 0, 1, 1, 0, -1, $gmt), $this->_Date->mktime(0, $minute, 0, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::SECOND:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, intval($date), 1, 1, 0, -1, $gmt), $this->_Date->mktime(0, 0, $second, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::MILLISECOND:
             switch ($calc) {
                 case 'set':
                     return $this->setMillisecond(intval($date));
                     break;
                 case 'add':
                     return $this->addMillisecond(intval($date));
                     break;
                 case 'sub':
                     return $this->subMillisecond(intval($date));
                     break;
             }
             return $this->compareMillisecond(intval($date));
             break;
         case Zend_Date::MINUTE_SHORT:
             return $this->_assign($calc, $this->_Date->mktime(0, intval($date), 0, 1, 1, 0, -1, $gmt), $this->_Date->mktime(0, $minute, 0, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::SECOND_SHORT:
             return $this->_assign($calc, $this->_Date->mktime(0, 0, intval($date), 1, 1, 0, -1, $gmt), $this->_Date->mktime(0, 0, $second, 1, 1, 0, -1, $gmt));
             break;
             // timezone formats
             // break intentionally omitted
         // timezone formats
         // break intentionally omitted
         case Zend_Date::TIMEZONE_NAME:
         case Zend_Date::DAYLIGHT:
         case Zend_Date::GMT_DIFF:
         case Zend_Date::GMT_DIFF_SEP:
         case Zend_Date::TIMEZONE:
         case Zend_Date::TIMEZONE_SECS:
             return false;
             break;
             // date strings
         // date strings
         case Zend_Date::ISO_8601:
             $result = preg_match('/\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{4}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $years = substr($match[0], 0, 4);
             $months = substr($match[0], 5, 2);
             $days = substr($match[0], 8, 2);
             $hours = substr($match[0], 11, 2);
             $minutes = substr($match[0], 14, 2);
             $seconds = substr($match[0], 17, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::RFC_2822:
             $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $days = substr($match[0], 5, 2);
             $months = $this->getDigitFromName(substr($match[0], 8, 3));
             $years = substr($match[0], 12, 4);
             $hours = substr($match[0], 17, 2);
             $minutes = substr($match[0], 20, 2);
             $seconds = substr($match[0], 23, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::TIMESTAMP:
             if (is_numeric($date)) {
                 return $this->_assign($calc, $date, $this->getTimestamp());
             }
             return false;
             break;
             // additional formats
             // break intentionally omitted
         // additional formats
         // break intentionally omitted
         case Zend_Date::ERA:
         case Zend_Date::ERA_NAME:
             return false;
             break;
         case Zend_Date::DATES:
             $parsed = Zend_Locale_Format::getDate($date, 'default', $locale);
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, $parsed['month'], $parsed['day'], $parsed['year'], -1, $gmt), $this->_Date->mktime(0, 0, 0, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::DATE_FULL:
             $parsed = Zend_Locale_Format::getDate($date, 'full', $locale);
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, $parsed['month'], $parsed['day'], $parsed['year'], -1, $gmt), $this->_Date->mktime(0, 0, 0, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::DATE_LONG:
             $parsed = Zend_Locale_Format::getDate($date, 'long', $locale);
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, $parsed['month'], $parsed['day'], $parsed['year'], -1, $gmt), $this->_Date->mktime(0, 0, 0, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::DATE_MEDIUM:
             $parsed = Zend_Locale_Format::getDate($date, 'medium', $locale);
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, $parsed['month'], $parsed['day'], $parsed['year'], -1, $gmt), $this->_Date->mktime(0, 0, 0, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::DATE_SHORT:
             $parsed = Zend_Locale_Format::getDate($date, 'short', $locale);
             return $this->_assign($calc, $this->_Date->mktime(0, 0, 0, $parsed['month'], $parsed['day'], $parsed['year'], -1, $gmt), $this->_Date->mktime(0, 0, 0, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::TIMES:
             $parsed = Zend_Locale_Format::getTime($date, 'default', $locale);
             return $this->_assign($calc, $this->_Date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::TIME_FULL:
             $parsed = Zend_Locale_Format::getTime($date, 'full', $locale);
             return $this->_assign($calc, $this->_Date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::TIME_LONG:
             $parsed = Zend_Locale_Format::getTime($date, 'long', $locale);
             return $this->_assign($calc, $this->_Date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::TIME_MEDIUM:
             $parsed = Zend_Locale_Format::getTime($date, 'medium', $locale);
             return $this->_assign($calc, $this->_Date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::TIME_SHORT:
             $parsed = Zend_Locale_Format::getTime($date, 'short', $locale);
             return $this->_assign($calc, $this->_Date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1, 1, 0, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, 1, 1, 0, -1, $gmt));
             break;
         case Zend_Date::ATOM:
             $result = preg_match('/\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{2}:\\d{2}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $years = substr($match[0], 0, 4);
             $months = substr($match[0], 5, 2);
             $days = substr($match[0], 8, 2);
             $hours = substr($match[0], 11, 2);
             $minutes = substr($match[0], 14, 2);
             $seconds = substr($match[0], 17, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::COOKIE:
             $result = preg_match('/\\w{6,9},\\s\\d{2}-\\w{3}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\s\\w{3}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $match[0] = substr($match[0], strpos(' ' + 1));
             $days = substr($match[0], 0, 2);
             $months = $this->getDigitFromName(substr($match[0], 3, 3));
             $years = substr($match[0], 7, 4);
             $years += 2000;
             $hours = substr($match[0], 10, 2);
             $minutes = substr($match[0], 13, 2);
             $seconds = substr($match[0], 16, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::RFC_822:
             $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $days = substr($match[0], 5, 2);
             $months = $this->getDigitFromName(substr($match[0], 8, 3));
             $years = substr($match[0], 12, 4);
             $years += 2000;
             $hours = substr($match[0], 15, 2);
             $minutes = substr($match[0], 18, 2);
             $seconds = substr($match[0], 21, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::RFC_850:
             $result = preg_match('/\\w{6,9},\\s\\d{2}-\\w{3}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\s\\w{3}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $match[0] = substr($match[0], strpos(' ' + 1));
             $days = substr($match[0], 0, 2);
             $months = $this->getDigitFromName(substr($match[0], 3, 3));
             $years = substr($match[0], 7, 4);
             $years += 2000;
             $hours = substr($match[0], 10, 2);
             $minutes = substr($match[0], 13, 2);
             $seconds = substr($match[0], 16, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::RFC_1036:
             $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{2}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $days = substr($match[0], 5, 2);
             $months = $this->getDigitFromName(substr($match[0], 8, 3));
             $years = substr($match[0], 12, 4);
             $years += 2000;
             $hours = substr($match[0], 15, 2);
             $minutes = substr($match[0], 18, 2);
             $seconds = substr($match[0], 21, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::RFC_1123:
             $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $days = substr($match[0], 5, 2);
             $months = $this->getDigitFromName(substr($match[0], 8, 3));
             $years = substr($match[0], 12, 4);
             $hours = substr($match[0], 17, 2);
             $minutes = substr($match[0], 20, 2);
             $seconds = substr($match[0], 23, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::RSS:
             $result = preg_match('/\\w{3},\\s\\d{2}\\s\\w{3}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2}\\s\\+\\d{4}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $days = substr($match[0], 5, 2);
             $months = $this->getDigitFromName(substr($match[0], 8, 3));
             $years = substr($match[0], 12, 4);
             $hours = substr($match[0], 17, 2);
             $minutes = substr($match[0], 20, 2);
             $seconds = substr($match[0], 23, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         case Zend_Date::W3C:
             $result = preg_match('/\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+\\d{2}:\\d{2}/', $date, $match);
             if (!$result) {
                 return false;
             }
             $years = substr($match[0], 0, 4);
             $months = substr($match[0], 5, 2);
             $days = substr($match[0], 8, 2);
             $hours = substr($match[0], 11, 2);
             $minutes = substr($match[0], 14, 2);
             $seconds = substr($match[0], 17, 2);
             return $this->_assign($calc, $this->_Date->mktime($hours, $minutes, $seconds, $months, $days, $years, -1, $gmt), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
         default:
             return $this->_assign($calc, $this->getTimestamp(), $this->_Date->mktime($hour, $minute, $second, $month, $day, $year, -1, $gmt));
             break;
     }
 }