Example #1
0
 private function _checkFormat($value)
 {
     try {
         require_once 'Zend/Locale/Format.php';
         $parsed = Zend_Locale_Format::getDate($value, array('date_format' => $this->_format, 'format_type' => 'iso', 'fix_date' => false));
         if (isset($parsed['year']) and (strpos(strtoupper($this->_format), 'YY') !== false and strpos(strtoupper($this->_format), 'YYYY') === false)) {
             $parsed['year'] = Zend_Date::getFullYear($parsed['year']);
         }
     } catch (Exception $e) {
         // Date can not be parsed
         return false;
     }
     if ((strpos($this->_format, 'Y') !== false or strpos($this->_format, 'y') !== false) and !isset($parsed['year'])) {
         // Year expected but not found
         return false;
     }
     if (strpos($this->_format, 'M') !== false and !isset($parsed['month'])) {
         // Month expected but not found
         return false;
     }
     if (strpos($this->_format, 'd') !== false and !isset($parsed['day'])) {
         // Day expected but not found
         return false;
     }
     if ((strpos($this->_format, 'H') !== false or strpos($this->_format, 'h') !== false) and !isset($parsed['hour'])) {
         // Hour expected but not found
         return false;
     }
     if (strpos($this->_format, 'm') !== false and !isset($parsed['minute'])) {
         // Minute expected but not found
         return false;
     }
     if (strpos($this->_format, 's') !== false and !isset($parsed['second'])) {
         // Second expected  but not found
         return false;
     }
     // Date fits the format
     return true;
 }
Example #2
0
 public function testGetFullYear()
 {
     $this->assertSame(1970, Zend_Date::getFullYear(70));
     $this->assertSame(1999, Zend_Date::getFullYear(99));
     $this->assertSame(2000, Zend_Date::getFullYear(0));
     $this->assertSame(2037, Zend_Date::getFullYear(37));
     $this->assertSame(2069, Zend_Date::getFullYear(69));
     $this->assertSame(-4, Zend_Date::getFullYear(-4));
     $this->assertSame(100, Zend_Date::getFullYear(100));
 }