예제 #1
0
파일: DateTest.php 프로젝트: cargomedia/cm
 public function testValidateWithEnvironmentTimezone()
 {
     $formField = new CM_FormField_Date();
     $environment = new CM_Frontend_Environment(null, null, null, new DateTimeZone('Asia/Tokyo'));
     $value = $formField->validate($environment, ['year' => 2015, 'month' => 03, 'day' => 02]);
     $this->assertEquals(new DateTime('2015-03-02 00:00:00', new DateTimeZone('Asia/Tokyo')), $value);
 }
예제 #2
0
파일: Birthdate.php 프로젝트: cargomedia/cm
 public function validate(CM_Frontend_Environment $environment, $userInput)
 {
     $userInput = parent::validate($environment, $userInput);
     $age = $userInput->diff(new DateTime())->y;
     if ($age < $this->_minAge || $age > $this->_maxAge) {
         throw new CM_Exception_FormFieldValidation(new CM_I18n_Phrase('Invalid birthdate'));
     }
     return $userInput;
 }