<commit_before><?php

class Application_Form_AddShowWhen extends Zend_Form_SubForm
{

    public function init()
    {
		// Add start date element
        $this->addElement('text', 'add_show_start_date', array(
            'label'      => 'Date Start:',
            'class'      => 'input_text',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
				'NotEmpty',
        		array('date', false, array('YYYY-MM-DD'))
    		) 
        ));

		// Add start time element
        $this->addElement('text', 'add_show_start_time', array(
            'label'      => 'Start Time:',
            'class'      => 'input_text',
            'required'   => true,
            'filters'    => array('StringTrim'),
			'validators' => array(
				'NotEmpty',
        		array('date', false, array('HH:mm'))
    		) 
        ));

		// Add duration element
        $this->addElement('text', 'add_show_duration', array(
            'label'      => 'Duration:',
            'class'      => 'input_text',
            'required'   => true,
            'filters'    => array('StringTrim'),
			'validators' => array(
				'NotEmpty',
        		array('regex', false, array('([0-2][0-3]:[0-5][0-5])', 'messages' => 'Show must be under 24 hours'))
    		) 
        ));

		// Add repeats element
		$this->addElement('checkbox', 'add_show_repeats', array(
            'label'      => 'repeats',
            'required'   => false,
		));

    }

    public function checkReliantFields($formData) {
       
        $valid = true;

        $now_timestamp = date("Y-m-d H:i:s");
        $start_timestamp = $formData['add_show_start_date']."".$formData['add_show_start_time'];

        $now_epoch = strtotime($now_timestamp);
        $start_epoch = strtotime($start_timestamp);

        if($start_epoch < $now_epoch) {
            $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
            $valid = false;
        }

        if(strtotime("23:59") < strtotime($formData["add_show_duration"])) {
            $this->getElement('add_show_duration')->setErrors(array('Max show size: 23:59'));
            $valid = false;
        }
 
        return $valid;
    }

}
<commit_msg>add check for duration 00:00<commit_after><?php

class Application_Form_AddShowWhen extends Zend_Form_SubForm
{

    public function init()
    {
		// Add start date element
        $this->addElement('text', 'add_show_start_date', array(
            'label'      => 'Date Start:',
            'class'      => 'input_text',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
				'NotEmpty',
        		array('date', false, array('YYYY-MM-DD'))
    		) 
        ));

		// Add start time element
        $this->addElement('text', 'add_show_start_time', array(
            'label'      => 'Start Time:',
            'class'      => 'input_text',
            'required'   => true,
            'filters'    => array('StringTrim'),
			'validators' => array(
				'NotEmpty',
        		array('date', false, array('HH:mm'))
    		) 
        ));

		// Add duration element
        $this->addElement('text', 'add_show_duration', array(
            'label'      => 'Duration:',
            'class'      => 'input_text',
            'required'   => true,
            'filters'    => array('StringTrim'),
			'validators' => array(
				'NotEmpty',
                array('date', false, array('HH:mm', 'messages' => 'Show must be under 24 hours'))
    		) 
        ));

		// Add repeats element
		$this->addElement('checkbox', 'add_show_repeats', array(
            'label'      => 'repeats',
            'required'   => false,
		));

    }

    public function checkReliantFields($formData) {
       
        $valid = true;

        $now_timestamp = date("Y-m-d H:i:s");
        $start_timestamp = $formData['add_show_start_date']."".$formData['add_show_start_time'];

        $now_epoch = strtotime($now_timestamp);
        $start_epoch = strtotime($start_timestamp);

        if($start_epoch < $now_epoch) {
            $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
            $valid = false;
        }

        if(strtotime("00:00") == strtotime($formData["add_show_duration"])) {
            $this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00:00'));
            $valid = false;
        }
 
        return $valid;
    }

}

{'fraction_non_alphanumeric': 0.16159146476994887, 'fraction_numerical': 0.007112691709268726, 'mean_word_length': 2.0758714969241283, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3724919', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1370, 'n_words': 250}