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


PHP DateTimeUtil::isValidDbFormattedDateTime方法代码示例

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


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

示例1: validateAttribute

 /**
  * Validates the attribute of the model.
  * If there is any error, the error message is added to the model.
  * @param RedBeanModel $model the model being validated
  * @param string $attribute the attribute being validated
  */
 protected function validateAttribute($object, $attribute)
 {
     $value = $object->{$attribute};
     if ($this->allowEmpty && $this->isEmpty($value)) {
         return;
     }
     switch ($this->type) {
         case 'blob':
         case 'longblob':
             return;
         case 'integer':
             $valid = preg_match('/^[-+]?[0-9]+$/', trim($value));
             // Not Coding Standard
             break;
         case 'float':
             $valid = preg_match('/^[-+]?([0-9]*\\.)?[0-9]+([eE][-+]?[0-9]+)?$/', trim($value));
             // Not Coding Standard
             break;
         case 'date':
             $valid = DateTimeUtil::isValidDbFormattedDate($value);
             break;
         case 'time':
             $valid = CDateTimeParser::parse($value, $this->timeFormat) !== false;
             break;
         case 'datetime':
             $valid = DateTimeUtil::isValidDbFormattedDateTime($value);
             break;
         case 'array':
             $valid = is_array($value);
             break;
         case 'string':
         default:
             return;
     }
     if (!$valid) {
         if ($this->message !== null) {
             $message = $this->message;
         } else {
             $message = Zurmo::t('Core', '{attribute} must be {type}.');
         }
         $this->addError($object, $attribute, $message, array('{type}' => $this->type));
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:49,代码来源:TypeValidator.php

示例2: testIsValidDbFormattedDateTime

 public function testIsValidDbFormattedDateTime()
 {
     $this->assertTrue(DateTimeUtil::isValidDbFormattedDateTime('2011-09-23 23:23:23'));
     $this->assertTrue(DateTimeUtil::isValidDbFormattedDateTime('1756-01-01 00:59:59'));
     $this->assertFalse(DateTimeUtil::isValidDbFormattedDateTime('0011-09-23 23:23:23'));
     $this->assertFalse(DateTimeUtil::isValidDbFormattedDateTime('2011-13-32 23:23:23'));
     $this->assertFalse(DateTimeUtil::isValidDbFormattedDateTime('1011-09-23 24:23:23'));
     $this->assertFalse(DateTimeUtil::isValidDbFormattedDateTime('2011-12-32 23:23:23'));
     $this->assertFalse(DateTimeUtil::isValidDbFormattedDateTime('2011-12-32 23:60:23'));
     $this->assertFalse(DateTimeUtil::isValidDbFormattedDateTime('2011-12-32 23:23:60'));
     $this->assertFalse(DateTimeUtil::isValidDbFormattedDateTime('cascacasc'));
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:12,代码来源:DateTimeUtilTest.php

示例3: processGetModifiedItems

 /**
  * Get array of modified items since beginning or since datetime in past
  * @param $params
  * @return ApiResult
  * @throws ApiException
  */
 public function processGetModifiedItems($params)
 {
     try {
         $modelClassName = $this->getModelName();
         $stateMetadataAdapterClassName = $this->resolveStateMetadataAdapterClassName();
         if (!isset($params['sinceDateTime'])) {
             $sinceTimestamp = 0;
         } else {
             if (DateTimeUtil::isValidDbFormattedDateTime($params['sinceDateTime'])) {
                 $sinceTimestamp = DateTimeUtil::convertDbFormatDateTimeToTimestamp($params['sinceDateTime']);
             } else {
                 $message = 'sinceDateTime format is not correct. sinceDateTime should be in "YYYY-MM-DD HH:MM:SS" format';
                 throw new ApiException($message);
             }
         }
         $pageSize = Yii::app()->pagination->getGlobalValueByType('apiListPageSize');
         if (isset($params['pagination']['pageSize'])) {
             $pageSize = (int) $params['pagination']['pageSize'];
         }
         // Get offset. Please note that API client provide page number, and we need to convert it into offset,
         // which is parameter of RedBeanModel::getSubset function
         if (isset($params['pagination']['page']) && (int) $params['pagination']['page'] > 0) {
             $currentPage = (int) $params['pagination']['page'];
         } else {
             $currentPage = 1;
         }
         $offset = $this->getOffsetFromCurrentPageAndPageSize($currentPage, $pageSize);
         $models = ModelStateChangesSubscriptionUtil::getUpdatedModels($modelClassName, $pageSize, $offset, $sinceTimestamp, $stateMetadataAdapterClassName, Yii::app()->user->userModel);
         $totalItems = ModelStateChangesSubscriptionUtil::getUpdatedModelsCount($modelClassName, $sinceTimestamp, $stateMetadataAdapterClassName, Yii::app()->user->userModel);
         $data = array('totalCount' => $totalItems, 'pageSize' => $pageSize, 'currentPage' => $currentPage);
         if (is_array($models) && !empty($models)) {
             foreach ($models as $model) {
                 $data['items'][] = static::getModelToApiDataUtilData($model);
             }
             $result = new ApiResult(ApiResponse::STATUS_SUCCESS, $data, null, null);
         } else {
             $result = new ApiResult(ApiResponse::STATUS_SUCCESS, $data, null, null);
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         throw new ApiException($message);
     }
     return $result;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:50,代码来源:ZurmoModuleApiController.php


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