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


PHP Formatter::parseDateTime方法代码示例

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


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

示例1: actionSaveGoogleEvent

 public function actionSaveGoogleEvent($calendarId)
 {
     if (isset($_POST['EventId'])) {
         $eventId = $_POST['EventId'];
         $calendar = X2Calendar::model()->findByPk($calendarId);
         $googleCalendar = $calendar->getGoogleCalendar();
         $googleEvent = $googleCalendar->events->get($calendar->googleCalendarId, $eventId);
         $model = new Actions();
         foreach ($model->attributes as $field => $value) {
             if (isset($_POST['Actions'][$field])) {
                 $model->{$field} = $_POST['Actions'][$field];
             }
         }
         if ($model->allDay) {
             $googleEvent['start']['date'] = date('Y-m-d', Formatter::parseDateTime($model->dueDate));
             if ($model->completeDate) {
                 $googleEvent['end']['date'] = date('Y-m-d', Formatter::parseDateTime($model->completeDate) + 86400);
             }
             if (isset($googleEvent['start']['dateTime'])) {
                 unset($googleEvent['start']['dateTime']);
             }
             if (isset($googleEvent['end']['dateTime'])) {
                 unset($googleEvent['end']['dateTime']);
             }
         } else {
             $googleEvent['start']['dateTime'] = date('c', Formatter::parseDateTime($model->dueDate));
             if ($model->completeDate) {
                 $googleEvent['end']['dateTime'] = date('c', Formatter::parseDateTime($model->completeDate));
             }
             if (isset($googleEvent['start']['date'])) {
                 unset($googleEvent['start']['date']);
             }
             if (isset($googleEvent['end']['date'])) {
                 unset($googleEvent['end']['date']);
             }
         }
         if ($model->color && $model->color != '#3366CC') {
             $colorTable = array(10 => 'Green', 11 => 'Red', 6 => 'Orange', 8 => 'Black');
             if (($key = array_search($model->color, $colorTable)) != false) {
                 $googleEvent['colorId'] = $key;
             }
         }
         $googleEvent = new Event($googleEvent);
         // we send back a proper Event object to google
         $googleEvent->setSummary($_POST['Actions']['actionDescription']);
         $googleCalendar->events->update($calendar->googleCalendarId, $eventId, $googleEvent);
         //            $googleCalendar->events->delete($calendar->googleCalendarId, $eventId);
     }
     //        $this->render('test', array('model'=>$_POST));
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:50,代码来源:CalendarController.php

示例2: beforeSave

 /**
  * Fixes up record association, parses dates (since this doesn't use 
  * {@link X2Model::setX2Fields()})
  * @return boolean whether or not to save
  */
 public function beforeSave()
 {
     if ($this->scenario !== 'workflow') {
         $association = self::getAssociationModel($this->associationType, $this->associationId);
         if ($association === null) {
             $this->associationName = 'None';
             $this->associationId = 0;
         } else {
             if ($association->hasAttribute('name')) {
                 $this->associationName = $association->name;
             }
             if ($association->asa('X2TimestampBehavior') !== null) {
                 if ($association->asa('changelog') !== null && Yii::app()->getSuName() == 'Guest') {
                     $association->disableBehavior('changelog');
                 }
                 $association->updateLastActivity();
                 $association->enableBehavior('changelog');
             }
         }
         if ($this->associationName == 'None' && $this->associationType != 'none') {
             $this->associationName = ucfirst($this->associationType);
         }
         $this->dueDate = Formatter::parseDateTime($this->dueDate);
         $this->completeDate = Formatter::parseDateTime($this->completeDate);
     }
     // Whether this is a "timed" action record:
     $timed = $this->isTimedType;
     if (empty($timeSpent) && !empty($this->completeDate) && !empty($this->dueDate) && $timed) {
         $this->timeSpent = $this->completeDate - $this->dueDate;
     }
     return parent::beforeSave();
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:37,代码来源:Actions.php

示例3: parseValue

 /**
  * Parses a value for table insertion using X2Fields rules
  * @param mixed $value
  * @param bool $filter If true, replace HTML special characters (prevents markup injection)
  * @return mixed the parsed value
  */
 public function parseValue($value, $filter = false)
 {
     if (in_array($this->type, array('int', 'float', 'currency', 'percentage'))) {
         return self::strToNumeric($value, $this->type);
     }
     switch ($this->type) {
         case 'assignment':
             return $this->linkType === 'multiple' ? self::parseUsers($value) : $value;
         case 'date':
         case 'dateTime':
             if (is_numeric((string) $value)) {
                 // must already be a timestamp
                 return $value;
             }
             $value = $this->type === 'dateTime' ? Formatter::parseDateTime($value) : Formatter::parseDate($value);
             return $value === false ? null : $value;
         case 'link':
             if (empty($value) || empty($this->linkType)) {
                 return $value;
             }
             list($name, $id) = self::nameAndId($value);
             if (ctype_digit((string) $id)) {
                 // Already formatted as a proper reference. Check for existence of the record.
                 $linkedModel = X2Model::model($this->linkType)->findByAttributes(array('nameId' => $value));
                 // Return the plain text name if the link is broken; otherwise,
                 // given how the record exists, return the value.
                 return empty($linkedModel) ? $name : $value;
             } else {
                 if (ctype_digit($value)) {
                     // User manually entered the ID, i.e. in an API call
                     $link = Yii::app()->db->createCommand()->select('nameId')->from(X2Model::model($this->linkType)->tableName())->where('id=?', array($value))->queryScalar();
                 } else {
                     // Look up model's unique nameId by its name:
                     $link = Yii::app()->db->createCommand()->select('nameId')->from(X2Model::model($this->linkType)->tableName())->where('name=?', array($name))->queryScalar();
                 }
             }
             return $link === false ? $name : $link;
         case 'boolean':
             return (bool) $value;
         case 'text':
             return self::getPurifier()->purify($value);
         case 'dropdown':
             return is_array($value) ? CJSON::encode($value) : $value;
         default:
             return $filter ? CHtml::encode($value) : $value;
     }
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:53,代码来源:Fields.php

示例4: parseValue

 public static function parseValue($value, $type, &$params = null, $renderFlag = true)
 {
     if (is_string($value)) {
         if (strpos($value, '=') === 0) {
             // It's a formula. Evaluate it.
             $evald = X2FlowFormatter::parseFormula($value, $params);
             // Fail silently because there's not yet a good way of reporting
             // problems that occur in parseFormula --
             $value = '';
             if ($evald[0]) {
                 $value = $evald[1];
             }
         } else {
             // Run token replacement:
             $value = X2FlowFormatter::replaceVariables($value, $params, $type, $renderFlag, true);
         }
     }
     switch ($type) {
         case 'boolean':
             return (bool) $value;
         case 'time':
         case 'date':
         case 'dateTime':
             if (ctype_digit((string) $value)) {
                 // must already be a timestamp
                 return $value;
             }
             if ($type === 'date') {
                 $value = Formatter::parseDate($value);
             } elseif ($type === 'dateTime') {
                 $value = Formatter::parseDateTime($value);
             } else {
                 $value = strtotime($value);
             }
             return $value === false ? null : $value;
         case 'link':
             $pieces = explode('_', $value);
             if (count($pieces) > 1) {
                 return $pieces[0];
             }
             return $value;
         case 'tags':
             return Tags::parseTags($value);
         default:
             return $value;
     }
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:47,代码来源:X2Flow.php

示例5: actionQuickUpdate

 public function actionQuickUpdate($id)
 {
     $model = $this->loadModel($id);
     if (isset($_POST['Actions'])) {
         $model->setX2Fields($_POST['Actions']);
         $model->dueDate = Formatter::parseDateTime($model->dueDate);
         if ($model->completeDate) {
             $model->completeDate = Formatter::parseDateTime($model->completeDate);
         } elseif (empty($model->completeDate)) {
             $model->completeDate = $model->dueDate;
         }
         if ($model->save()) {
             $model->syncGoogleCalendar('update');
         }
         if (isset($_POST['isEvent']) && $_POST['isEvent']) {
             // Update calendar event
             $event = X2Model::model('Events')->findByAttributes(array('associationType' => 'Actions', 'associationId' => $model->id));
             if ($event !== null) {
                 $event->timestamp = $model->dueDate;
                 $event->update(array('timestamp'));
             }
         }
     }
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:24,代码来源:ActionsController.php

示例6: importRecordAttribute

 /**
  * The import assumes we have human readable data in the CSV and will thus need to convert. This
  * method converts link, date, and dateTime fields to the appropriate machine friendly data.
  * @param string $modelName The model class being imported
  * @param X2Model $model The currently importing model record
  * @param string $fieldName Field to set
  * @param string $importAttribute Value to set field
  * @returns X2Model $model
  */
 protected function importRecordAttribute($modelName, X2Model $model, $fieldName, $importAttribute)
 {
     $fieldRecord = Fields::model()->findByAttributes(array('modelName' => $modelName, 'fieldName' => $fieldName));
     // Skip setting the attribute if it has already been set or if the entry from
     // the CSV is empty.
     if (empty($importAttribute) && ($importAttribute !== 0 && $importAttribute !== '0')) {
         return $model;
     }
     if ($fieldName === 'actionDescription' && $modelName === 'Actions') {
         $text = new ActionText();
         $text->text = $importAttribute;
         if (isset($model->id)) {
             $text->actionId = $model->id;
         }
         $this->setCurrentActionText($text->attributes);
         return $model;
     }
     // ensure the provided id is valid
     if (strtolower($fieldName) === 'id' && (!preg_match('/^\\d+$/', $importAttribute) || $importAttribute >= 4294967295)) {
         $model->id = $importAttribute;
         $model->addError('id', Yii::t('importexport', "ID '{$importAttribute}' is not valid."));
         return $model;
     }
     switch ($fieldRecord->type) {
         case "link":
             $model = $this->importRecordLinkAttribute($modelName, $model, $fieldRecord, $importAttribute);
             break;
         case "dateTime":
         case "date":
             if (Formatter::parseDateTime($importAttribute) !== false) {
                 $model->{$fieldName} = Formatter::parseDateTime($importAttribute);
             }
             break;
         case "visibility":
             switch ($importAttribute) {
                 case 'Private':
                     $model->{$fieldName} = 0;
                     break;
                 case 'Public':
                     $model->{$fieldName} = 1;
                     break;
                 case 'User\'s Groups':
                     $model->{$fieldName} = 2;
                     break;
                 default:
                     $model->{$fieldName} = $importAttribute;
             }
             break;
         default:
             $model->{$fieldName} = $importAttribute;
     }
     return $model;
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:62,代码来源:ImportExportBehavior.php


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