コード例 #1
0
 protected function getDbDate()
 {
     if (!($s = $this->_control->getText())) {
         return NULL;
     }
     $formatter = new TSimpleDateFormatter($this->_dateFormat);
     $formatterDb = new TSimpleDateFormatter('yyyy-MM-dd');
     if (($ts = $formatter->parse($s)) == false) {
         throw new TInvalidDataTypeException('Invalid date input. (The validator should have caught that already)');
     }
     //TODO Put to messages
     $dbDate = $formatterDb->format($ts);
     if (!$dbDate) {
         throw new TInvalidDataTypeException('Invalid date input. (The validator should have caught that already)');
     }
     //TODO Put to messages
     return $dbDate;
 }
コード例 #2
0
 public function testMissingYearPattern()
 {
     $formatter = new TSimpleDateFormatter("MM/dd");
     self::assertEquals(date("Y-10-22"), date('Y-m-d', $formatter->parse("10/22")));
 }