当前位置: 首页>>代码示例>>PHP>>正文


PHP Validation::time方法代码示例

本文整理汇总了PHP中Validation::time方法的典型用法代码示例。如果您正苦于以下问题:PHP Validation::time方法的具体用法?PHP Validation::time怎么用?PHP Validation::time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validation的用法示例。


在下文中一共展示了Validation::time方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkDatetimeType

 /**
  * checkDatetimeType
  *
  * @param array $question question
  * @param string $answer answer value
  * @return array error message
  */
 public function checkDatetimeType($question, $answer)
 {
     $errors = array();
     if ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_DATE) {
         if (!Validation::date($answer, 'ymd')) {
             $errors[] = sprintf(__d('questionnaires', 'Please enter a valid date in YY-MM-DD format.'));
         }
     } elseif ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_TIME) {
         if (!Validation::time($answer)) {
             $errors[] = sprintf(__d('questionnaires', 'Please enter the time.'));
         }
     } elseif ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_DATE_TIME) {
         if (!Validation::datetime($answer, 'ymd')) {
             $errors[] = sprintf(__d('questionnaires', 'Please enter a valid date and time.'));
         }
     }
     return $errors;
 }
开发者ID:Onasusweb,项目名称:Questionnaires,代码行数:25,代码来源:QuestionnaireAnswerValidation.php

示例2: _validateDatetime

 /**
  * _validateDatetime 日付・時間の正当性
  *
  * @param object &$model use model
  * @param int $questionTypeOption 時間・日付オプション
  * @param string $answer 登録データ
  * @return bool
  */
 protected function _validateDatetime(&$model, $questionTypeOption, $answer)
 {
     if ($questionTypeOption == RegistrationsComponent::TYPE_OPTION_DATE) {
         if (!Validation::date($answer, 'ymd')) {
             $model->validationErrors['answer_value'][] = __d('registrations', 'Please enter a valid date in YY-MM-DD format.');
             return false;
         }
     } elseif ($questionTypeOption == RegistrationsComponent::TYPE_OPTION_TIME) {
         if (!Validation::time($answer)) {
             $model->validationErrors['answer_value'][] = __d('registrations', 'Please enter the time.');
             return false;
         }
     } elseif ($questionTypeOption == RegistrationsComponent::TYPE_OPTION_DATE_TIME) {
         if (!Validation::datetime($answer, 'ymd')) {
             $model->validationErrors['answer_value'][] = __d('registrations', 'Please enter a valid date and time.');
             return false;
         }
     } else {
         $model->validationErrors['answer_value'][] = __d('net_commons', 'Invalid request.');
         return false;
     }
     return true;
 }
开发者ID:NetCommons3,项目名称:Registrations,代码行数:31,代码来源:RegistrationAnswerDatetimeBehavior.php

示例3: testTime

 /**
  * testTime method
  *
  * @return void
  */
 public function testTime()
 {
     $this->assertTrue(Validation::time('00:00'));
     $this->assertTrue(Validation::time('23:59'));
     $this->assertFalse(Validation::time('24:00'));
     $this->assertTrue(Validation::time('12:00'));
     $this->assertTrue(Validation::time('12:01'));
     $this->assertTrue(Validation::time('12:01am'));
     $this->assertTrue(Validation::time('12:01pm'));
     $this->assertTrue(Validation::time('1pm'));
     $this->assertTrue(Validation::time('1 pm'));
     $this->assertTrue(Validation::time('1 PM'));
     $this->assertTrue(Validation::time('01:00'));
     $this->assertFalse(Validation::time('1:00'));
     $this->assertTrue(Validation::time('1:00pm'));
     $this->assertFalse(Validation::time('13:00pm'));
     $this->assertFalse(Validation::time('9:00'));
 }
开发者ID:alvaroziqar,项目名称:galei,代码行数:23,代码来源:ValidationTest.php

示例4: datetime

 /**
  * Validates a datetime value by acting as a decorator for native
  * Validation::date() and Validation::time() methods.
  *
  * @param   $check    array   field_name => value
  * @param   $options  array   Options for this rule
  * @return  boolean
  * @access  public
  */
 public function datetime($check, $options)
 {
     $check = array_shift(array_values($check));
     $datetime = strtotime($check);
     if ($datetime !== false) {
         return Validation::date(date('Y-m-d', $datetime), 'ymd') && Validation::time(date('H:i', $datetime));
     }
     return false;
 }
开发者ID:robwilkerson,项目名称:CakePHP-Boilerplate,代码行数:18,代码来源:app_model.php

示例5: testValidTimeWith12Hours2

 /**
  * @testdox time should return true to 12 hours format without leading zero
  */
 public function testValidTimeWith12Hours2()
 {
     $value = '6:00pm';
     $this->assertTrue(Validation::time($value));
 }
开发者ID:klawdyo,项目名称:spaghettiphp,代码行数:8,代码来源:ValidationTest.php

示例6: validateTime

 /**
  * @param options
  * - timeFormat (defaults to 'hms')
  * - allowEmpty
  * - after/before (fieldName to validate against)
  * - min/max (defaults to >= 1 - at least 1 minute apart)
  * 2011-03-02 ms
  */
 public function validateTime($data, $options = array())
 {
     if (is_array($data)) {
         $value = array_shift($data);
     } else {
         $value = $data;
     }
     $dateTime = explode(' ', trim($value), 2);
     $value = array_pop($dateTime);
     if (Validation::time($value)) {
         # after/before?
         if (!empty($options['after']) && isset($this->data[$this->alias][$options['after']])) {
             if ($this->data[$this->alias][$options['after']] >= $value) {
                 return false;
             }
         }
         if (!empty($options['before']) && isset($this->data[$this->alias][$options['before']])) {
             if ($this->data[$this->alias][$options['before']] <= $value) {
                 return false;
             }
         }
         return true;
     }
     return false;
 }
开发者ID:robksawyer,项目名称:grabitdown,代码行数:33,代码来源:MyModel.php


注:本文中的Validation::time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。