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); }
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; }