Symfony\Component\Form\TimeField::isHourWithinRange PHP Method

isHourWithinRange() public method

The hour is valid if it is contained in the list passed to the field's option "hours".
public isHourWithinRange ( ) : boolean
return boolean
    public function isHourWithinRange()
    {
        $date = $this->getNormalizedData();

        return $date === null || in_array($date->format('H'), $this->getOption('hours'));
    }

Usage Example

 public function testIsHourWithinRange_returnsFalseIfNotContained()
 {
     $field = new TimeField('name', array('hours' => array(6, 7)));
     $field->submit(array('hour' => '08', 'minute' => '12'));
     $this->assertFalse($field->isHourWithinRange());
 }