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


PHP CakeTime::isFuture方法代码示例

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


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

示例1: ageFromBirthdate

 /**
  * Calculates the current age of someone born on $birthdate.
  * Source: stackoverflow.com/questions/3776682/php-calculate-age
  * @param sing $birthdate The birthdate.
  * @return integer The calculated age.
  * @access public
  * @static
  */
 public static function ageFromBirthdate($birthdate)
 {
     // convert to format: YYYY-MM-DD
     $clean_birthdate = date('Y-m-d', CakeTime::fromString($birthdate));
     if (CakeTime::isFuture($clean_birthdate)) {
         throw new OutOfRangeException("Birthdate is in the future: {$clean_birthdate}", BedrockTime::EXCEPTION_CODE_FUTURE_BIRTHDATE);
     }
     //explode the date to get month, day and year
     $parts = explode('-', $clean_birthdate);
     //get age from date or birthdate
     $age = intval(date('md', date('U', mktime(0, 0, 0, $parts[1], $parts[2], $parts[0]))) > date('md') ? date('Y') - $parts[0] - 1 : date('Y') - $parts[0]);
     return $age;
 }
开发者ID:quentinhill,项目名称:bedrock,代码行数:21,代码来源:BedrockTime.php

示例2: days

 /**
  *    Days in theme
  *    @param int $theme_id
  */
 public function days($theme_id = null, $user_id = null)
 {
     if (!$theme_id) {
         return;
     }
     $options = array('recursive' => -1, 'conditions' => array('Day.theme_id' => $theme_id), 'order' => array('data ASC'));
     $rows = $this->Day->find('all', $options);
     foreach ($rows as $key => $row) {
         $row['Day']['isFuture'] = false;
         $row['Day']['isPast'] = false;
         $row['Day']['isToday'] = false;
         $row['Day']['comments'] = $this->Comment->find('count', array('conditions' => array('Comment.user_id' => !$this->isUser() ? $user_id : $this->getUserId(), 'Comment.day_id' => $row['Day']['id'])));
         if (CakeTime::isFuture($row['Day']['data'])) {
             $row['Day']['isFuture'] = true;
         }
         if (CakeTime::isPast($row['Day']['data'])) {
             $row['Day']['isPast'] = true;
         }
         if (CakeTime::isToday($row['Day']['data'])) {
             $row['Day']['isToday'] = true;
         }
         $data[] = $row['Day'];
     }
     $this->set($data);
     $this->set('_serialize', array_keys($data));
 }
开发者ID:ranostaj,项目名称:iqualJs,代码行数:30,代码来源:ThemesController.php

示例3: oldCopyRound

 public function oldCopyRound($projectId = null)
 {
     if ($this->request->is('post') || $this->request->is('put')) {
         //$this -> autoRender = false;
         if (!empty($this->request->data['Round']['Round'])) {
             $oldRoundId = $this->request->data['Round']['Round'];
             $round = $this->Round->find('first', array('recursive' => -1, 'conditions' => array('Round.id' => $oldRoundId)));
             if (trim($this->request->data['Round']['title']) == '' || !isset($this->request->data['Round']['title'])) {
                 $this->Session->setFlash('Please select one Title');
                 $this->redirect(array('controller' => 'rounds', 'action' => 'copyRound', $projectId));
             }
             App::uses('CakeTime', 'Utility');
             if (CakeTime::isFuture($round['Round']['ends_in_date'])) {
                 $this->Round->id = $round['Round']['id'];
                 $date = CakeTime::format('-1 days', '%Y-%m-%d');
                 $this->Round->saveField('ends_in_date', $date);
             }
             if (empty($this->request->data['Round']['User'])) {
                 $this->Session->setFlash('You must choose at least one user');
                 $this->redirect(array('controller' => 'rounds', 'action' => 'copyRound', $projectId));
             } else {
                 $oldRoundId = $this->request->data['Round']['Round'];
                 $this->Round->create();
                 $this->request->data['Round']['ends_in_date'] = NULL;
                 $users = $this->request->data['Round']['User'];
                 $conditions_userRounds = array('UsersRound.round_id' => $oldRoundId, 'UsersRound.user_id' => $users);
                 //guardamos los usuarios en condiciones
                 unset($this->request->data['Round']['User']);
                 $title = $this->request->data['Round']['title'];
                 $this->request->data['Round']['title'] = $title . '-[0%]';
                 $errors = "";
                 //$db = $this->Round->getDataSource();
                 //$db->begin();
                 if ($this->Round->save($this->request->data, false)) {
                     //se deshabilita el save para poder guardar rounds con ends_in_date = NULL
                     //esta bandera marcara que un round esta en estado de copia
                     $this->Session->setFlash('We are creating a new version of the round. Please be patient', 'information');
                     //cortamos la ejecucion parab el usuario pero el script sigue en ejecucion
                     //de esta forma el usuario puedeseguir navegando
                     $this->backGround(array('controller' => 'projects', 'action' => 'view', $round['Round']['project_id']));
                     $round_id = $this->Round->id;
                     $newRoundId = $this->Round->id;
                     $size_userRounds = $this->Round->UsersRound->find('count', array('recursive' => -1, 'conditions' => $conditions_userRounds));
                     /**
                      * tamaño de particiones
                      * Haremos una particion de los rounds para no sobrecargar la memoria
                      * ** */
                     if ($size_userRounds > 0) {
                         //hacemos partioces de user_rounds de 100
                         $particiones_userRounds = 100;
                         $size_userRounds_total = $size_userRounds;
                         //si el tamaño es mayor que la particion calculamos cuantas veces vamos a tener que hacer
                         if ($size_userRounds > $particiones_userRounds) {
                             $fin_userRounds = $size_userRounds / $particiones_userRounds;
                             //calculamos el numero de beces a la baja
                             // por ejemplo 2.5 se haces dos veces
                             $fin_userRounds = floor($fin_userRounds);
                             //si existe resto se hace una vez mas
                             if ($size_userRounds % $particiones_userRounds != 0) {
                                 $fin_userRounds++;
                             }
                         } else {
                             // si no la particion es = al tamaño
                             $particiones_userRounds = $size_userRounds;
                             $fin_userRounds = 1;
                         }
                         $contador_userRounds = 0;
                         $procces_userRounds = 0;
                         $time = date('Y-m-d H:i:s');
                         //variables para monotorizar la copia
                         $worked = 0;
                         $procces = 0;
                         while ($contador_userRounds < $fin_userRounds) {
                             $usersRounds = $this->Round->UsersRound->find('all', array('offset' => $procces_userRounds, 'limit' => $particiones_userRounds, 'recursive' => -1, 'fields' => array('UsersRound.id', 'UsersRound.user_id', 'UsersRound.document_id', 'UsersRound.text_marked'), 'conditions' => $conditions_userRounds));
                             //se eligen bucles for en vez de bucles foreach dado que son mas rapidos si se van a modificar datos
                             //http://www.phpbench.com/
                             $usersRoundTam = sizeof($usersRounds);
                             for ($i = 0; $i < $usersRoundTam; $i++) {
                                 $procces++;
                                 $worked = $procces / $size_userRounds_total * 100;
                                 if (round($worked) % 10 == 0) {
                                     $data = array('Round' => array('title' => $title . '-[' . round($worked) . '%]'));
                                     $this->Round->save($data);
                                 }
                                 $usersRounds[$i]['UsersRound']['created'] = $time;
                                 $conditions = array('Annotation.round_id' => $oldRoundId, 'Annotation.document_id' => $usersRounds[$i]['UsersRound']['document_id'], 'Annotation.user_id' => $usersRounds[$i]['UsersRound']['user_id'], 'Annotation.users_round_id' => $usersRounds[$i]['UsersRound']['id']);
                                 $textoForMatches = $usersRounds[$i]['UsersRound']['text_marked'];
                                 $usersRounds[$i]['UsersRound']['round_id'] = $newRoundId;
                                 unset($usersRounds[$i]['UsersRound']['id']);
                                 unset($usersRounds[$i]['UsersRound']['text_marked']);
                                 $this->Round->UsersRound->create();
                                 if ($this->Round->UsersRound->save($usersRounds[$i])) {
                                     $size_annotations = $this->Round->UsersRound->Annotation->find('count', array('recursive' => -1, 'conditions' => $conditions));
                                     if ($size_annotations > 0) {
                                         $parseKey = Configure::read('parseKey');
                                         $parseIdAttr = Configure::read('parseIdAttr');
                                         /**
                                          * Particiones de anotaciones
                                          */
                                         $particiones_annotations = 400;
//.........这里部分代码省略.........
开发者ID:sing-group,项目名称:Markyt,代码行数:101,代码来源:RoundsController.php

示例4: uploadFinalPredictions

 function uploadFinalPredictions()
 {
     $this->Cookie = $this->Components->load('Cookie');
     $this->Cookie->type('rijndael');
     //        $this->Cookie->time = '999 hours';
     if ($this->request->is(array('post', 'put'))) {
         //            debug($this->request->data);
         $email = $this->request->data['Participant']['email'];
         $code = $this->request->data['Participant']['code'];
         $task = $this->request->data['Participant']["task"];
         $run = $this->request->data['Participant']["run"];
         $maxUploadTask = Configure::read('max_participant_task_upload');
         $tasks = Configure::read('biocreative_tasks');
         $finalDate = Configure::read('final_date_to_upload_tasks');
         $startDate = Configure::read('initial_date_to_upload_tasks');
         if (!in_array($task, $tasks) && $run < 0 && $run > 5) {
             $this->Session->setFlash("Incorrect data");
             return $this->redirect(array('controller' => 'Participants', 'action' => 'analysis'));
         }
         App::uses('CakeTime', 'Utility');
         $isEnd = CakeTime::isPast($finalDate);
         $isFuture = CakeTime::isFuture($startDate);
         if ($isEnd || $isFuture) {
             $this->Session->setFlash("The final delivery date has expired");
             return $this->redirect(array('controller' => 'Participants', 'action' => 'analysis'));
         }
         $project_id = -1;
         if ($this->data['Participant']['remember_me'] && isset($code) && isset($email)) {
             $cookie = array();
             $cookie['email'] = $email;
             $cookie['code'] = $code;
             $this->Cookie->write('participantData', $cookie, true, '+2 weeks');
         } else {
             if ($this->Cookie->check('participantData')) {
                 $this->Cookie->destroy('participantData');
             }
         }
         App::uses('Folder', 'Utility');
         App::uses('File', 'Utility');
         //            debug($this->request->data);
         if ($this->request->data['Participant']['final_prediction']['size'] > 0) {
             /* ============================================= */
             /* ==============Load analysis=================== */
             /* ============================================= */
             if ($this->request->data['Participant']['final_prediction']['size'] > $this->filesize2bytes(Configure::read('max_file_size'))) {
                 $this->Session->setFlash("The file can not be more than " . Configure::read('max_file_size'));
                 return $this->redirect(array('controller' => 'Participants', 'action' => 'analysis'));
             }
             $file = $this->request->data['Participant']['final_prediction']['name'];
             if (pathinfo($file, PATHINFO_EXTENSION) != 'tsv') {
                 $this->Session->setFlash("The file must be in TSV format");
                 return $this->redirect(array('controller' => 'Participants', 'action' => 'analysis'));
             }
             $file = new File($this->request->data['Participant']['final_prediction']['tmp_name']);
             if ($file->readable()) {
                 $content = $file->read();
                 $file->close();
                 $lines = explode("\n", $content);
                 $incorrectFormat = empty($lines);
                 $count = 0;
                 $size = count($lines);
                 $correctColumns = 5;
                 if ($task == "CPD") {
                     $correctColumns = 4;
                 }
                 for ($index = 0; $index < $size; $index++) {
                     if (strlen(trim($lines[$index])) > 0) {
                         if (!$incorrectFormat) {
                             $columns = explode("\t", $lines[$index]);
                             for ($i = 0; $i < count($columns); $i++) {
                                 if (strlen(trim($columns[$i])) == 0) {
                                     $incorrectFormat = true;
                                 }
                             }
                             $incorrectFormat = $incorrectFormat || sizeof($columns) != $correctColumns;
                             $count++;
                         } else {
                             break;
                         }
                     }
                 }
                 //                    $correctFormat = $this->correctTsvFormat($file, 5);
                 if ($incorrectFormat) {
                     //                        $count=$this->incorrecLineTsvFormat($file);
                     if ($task == "CPD") {
                         $this->Session->setFlash("Incorrect content file. Line {$count} is incorrect. " . "Content file must be contain 4 columns");
                     } else {
                         $this->Session->setFlash("Incorrect content file. Line {$count} is incorrect. " . "Content file must be in this format WO2009026621A1->A:12:24->1->0.99->paliperidone");
                     }
                     return $this->redirect(array('controller' => 'Participants', 'action' => 'analysis'));
                 }
                 $participant = $this->Participant->find('first', array("recursive" => -1, "fields" => array("id", "team_id"), "conditions" => array('Participant.email' => $email, 'Participant.code' => $code)));
                 $participantID = $participant["Participant"]["id"];
                 $team_id = $participant["Participant"]["team_id"];
                 $this->request->data['Participant']['id'] = $participantID;
                 $this->participantSaveConnection($this->request->data['Participant'], "uploadTeamPrediction");
                 $path = Configure::read('participantsPath');
                 $path = $path . DS . $task . DS . $team_id;
                 $dir = new Folder($path, true, 0755);
                 $tempPath = $this->request->data['Participant']['final_prediction']['tmp_name'];
//.........这里部分代码省略.........
开发者ID:sing-group,项目名称:Markyt,代码行数:101,代码来源:ParticipantsController.php


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