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


PHP TimeSource::time方法代码示例

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


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

示例1: timeSinceInWords

 public function timeSinceInWords($data)
 {
     $diff = \TimeSource::time() - $data->getTimestamp();
     if ($diff < 0) {
         return "in the future";
     } elseif ($diff == 0) {
         return "now";
     } elseif ($diff == 1) {
         return "1 second ago";
     } elseif ($diff < 60) {
         return $diff . " seconds ago";
     } elseif ($diff < 60 * 2) {
         return "1 minute ago";
     } elseif ($diff < 60 * 60) {
         return round($diff / 60) . " minutes ago";
     } elseif ($diff < 60 * 60 * 2) {
         return "1 hour ago";
     } elseif ($diff < 60 * 60 * 24) {
         return round($diff / (60 * 60)) . " hours ago";
     } elseif ($diff < 60 * 60 * 24 * 2) {
         return "1 day ago";
     } else {
         return round($diff / (60 * 60 * 24)) . " days ago";
     }
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:25,代码来源:TimeSinceInWordsExtension.php

示例2: resendVerifyEmail

 function resendVerifyEmail(Request $request, Application $app)
 {
     $repo = new UserAccountVerifyEmailRepository();
     $date = $repo->getLastSentForUserAccount($app['currentUser']);
     if ($date && $date->getTimestamp() > \TimeSource::time() - $app['config']->userAccountVerificationSecondsBetweenAllowedSends) {
         $app['flashmessages']->addMessage("Sorry, but an email was sent too recently. Please try again later.");
     } else {
         $verifyEmail = $repo->create($app['currentUser']);
         $verifyEmail->sendEmail($app, $app['currentUser']);
         $app['flashmessages']->addMessage("Verification email resent.");
     }
     return $app->redirect("/me/");
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:13,代码来源:CurrentUserController.php

示例3: index

 function index(Request $request, Application $app)
 {
     $form = $app['form.factory']->create(new LogInUserForm());
     if ('POST' == $request->getMethod()) {
         $form->bind($request);
         if ($form->isValid()) {
             $data = $form->getData();
             if ($app['currentUser']->checkPassword($data['password']) && $data['extrapassword'] == $app['config']->sysAdminExtraPassword) {
                 $app['websession']->set('sysAdminLastActive', \TimeSource::time());
                 return $app->redirect("/sysadmin");
             } else {
                 $form->addError(new FormError('passwords wrong'));
             }
         }
     }
     return $app['twig']->render('sysadmin/login/index.html.twig', array('form' => $form->createView()));
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:17,代码来源:LogInController.php

示例4: processMeetupData

 protected function processMeetupData($meetupData)
 {
     global $CONFIG;
     $start = new \DateTime('', new \DateTimeZone('UTC'));
     $start->setTimestamp($meetupData->time / 1000);
     if (property_exists($meetupData, 'duration') && $meetupData->duration) {
         $end = new \DateTime('', new \DateTimeZone('UTC'));
         $end->setTimestamp($meetupData->time / 1000);
         $end->add(new \DateInterval("PT" . $meetupData->duration / 1000 . "S"));
     } else {
         $end = clone $start;
         $end->add(new \DateInterval("PT3H"));
     }
     if ($start && $end && $start <= $end) {
         if ($end->getTimeStamp() < \TimeSource::time()) {
             $this->countInPast++;
         } else {
             if ($start->getTimeStamp() > \TimeSource::time() + $CONFIG->importURLAllowEventsSecondsIntoFuture) {
                 $this->countToFarInFuture++;
             } else {
                 $importedEventRepo = new \repositories\ImportedEventRepository();
                 $id = "event_" . $meetupData->id . "@meetup.com";
                 $importedEvent = $importedEventRepo->loadByImportURLIDAndImportId($this->importURLRun->getImportURL()->getId(), $id);
                 $changesToSave = false;
                 if (!$importedEvent) {
                     if ($meetupData->status != 'cancelled') {
                         ++$this->countNew;
                         $importedEvent = new ImportedEventModel();
                         $importedEvent->setImportId($id);
                         $importedEvent->setImportUrlId($this->importURLRun->getImportURL()->getId());
                         $this->setImportedEventFromMeetupData($importedEvent, $meetupData);
                         $changesToSave = true;
                     }
                 } else {
                     ++$this->countExisting;
                     if ($meetupData->status == 'cancelled') {
                         if (!$importedEvent->getIsDeleted()) {
                             $importedEvent->setIsDeleted(true);
                             $changesToSave = true;
                         }
                     } else {
                         $changesToSave = $this->setImportedEventFromMeetupData($importedEvent, $meetupData);
                         // if was deleted, undelete
                         if ($importedEvent->getIsDeleted()) {
                             $importedEvent->setIsDeleted(false);
                             $changesToSave = true;
                         }
                     }
                 }
                 if ($changesToSave && $this->countSaved < $this->limitToSaveOnEachRun) {
                     ++$this->countSaved;
                     $this->importedEventsToEvents->addImportedEvent($importedEvent);
                     if ($importedEvent->getId()) {
                         if ($importedEvent->getIsDeleted()) {
                             $importedEventRepo->delete($importedEvent);
                         } else {
                             $importedEventRepo->edit($importedEvent);
                         }
                     } else {
                         $importedEventRepo->create($importedEvent);
                     }
                 }
             }
         }
     }
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:66,代码来源:ImportURLMeetupHandler.php

示例5: getNewMonthlyEventsOnSetDayInWeek

 /**
  * 
  * Gets new monthly events on the basis that the event is on the something day in the week.
  * eg. 2nd tuesday of month 
  * eg. 4th saturday in month
  * 
  * @param \models\EventModel $event
  * @param type $monthsInAdvance
  * @return \models\EventModel
  */
 public function getNewMonthlyEventsOnSetDayInWeek(EventModel $event, $daysInAdvance = 186)
 {
     // constants
     $interval = new \DateInterval('P1D');
     $timeZone = new \DateTimeZone($this->timeZoneName);
     $timeZoneUTC = new \DateTimeZone("UTC");
     // calculate which day of month it should be
     $dayOfWeek = $event->getStartAt()->format("N");
     $thisStart = new \DateTime($event->getStartAt()->format('Y-m-d H:i:s'), $timeZoneUTC);
     $thisEnd = new \DateTime($event->getEndAt()->format('Y-m-d H:i:s'), $timeZoneUTC);
     $thisStart->setTimeZone($timeZone);
     $thisEnd->setTimeZone($timeZone);
     $weekInMonth = 1;
     while ($thisStart->format('d') > 1) {
         $thisStart->sub($interval);
         $thisEnd->sub($interval);
         if ($thisStart->format("N") == $dayOfWeek) {
             ++$weekInMonth;
         }
     }
     // vars
     $out = array();
     $currentMonthLong = $thisStart->format('F');
     $currentMonthShort = $thisStart->format('M');
     $currentMonth = $thisStart->format('m');
     $currentWeekInMonth = 1;
     $loopStop = \TimeSource::time() + $daysInAdvance * 24 * 60 * 60;
     while ($thisStart->getTimestamp() < $loopStop) {
         $thisStart->add($interval);
         $thisEnd->add($interval);
         //print $thisStart->format("r")."  current month: ".$currentMonth." current week: ".$currentWeekInMonth."\n";
         if ($currentMonth != $thisStart->format('m')) {
             $currentMonth = $thisStart->format('m');
             $currentWeekInMonth = 1;
         }
         if ($thisStart->format("N") == $dayOfWeek) {
             if ($currentWeekInMonth == $weekInMonth && $thisStart->getTimestamp() > \TimeSource::time()) {
                 $start = clone $thisStart;
                 $end = clone $thisEnd;
                 $start->setTimeZone($timeZoneUTC);
                 $end->setTimeZone($timeZoneUTC);
                 $include = true;
                 if ($include) {
                     $newEvent = new EventModel();
                     $newEvent->setGroupId($event->getGroupId());
                     $newEvent->setVenueId($event->getVenueId());
                     $newEvent->setCountryId($event->getCountryId());
                     $newEvent->setEventRecurSetId($this->id);
                     $newEvent->setSummary($event->getSummary());
                     $newEvent->setDescription($event->getDescription());
                     $newEvent->setStartAt($start);
                     $newEvent->setEndAt($end);
                     foreach ($this->customFields as $customField) {
                         if ($event->hasCustomField($customField)) {
                             $newEvent->setCustomField($customField, $event->getCustomField($customField));
                         }
                     }
                     if (stripos($newEvent->getSummary(), $currentMonthLong) !== false) {
                         $newEvent->setSummary(str_ireplace($currentMonthLong, $newEvent->getStartAt()->format('F'), $newEvent->getSummary()));
                     } else {
                         if (stripos($newEvent->getSummary(), $currentMonthShort) !== false) {
                             $newEvent->setSummary(str_ireplace($currentMonthShort, $newEvent->getStartAt()->format('M'), $newEvent->getSummary()));
                         }
                     }
                     $out[] = $newEvent;
                 }
             }
             ++$currentWeekInMonth;
         }
     }
     return $out;
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:82,代码来源:EventRecurSetModel.php

示例6: die

///////////////////////////////////////////// SECURITY
if (!$app['currentUser']) {
    die("No");
}
if (!$app['currentUser']->getIsSystemAdmin()) {
    die("No");
}
if (!$WEBSESSION->has('sysAdminLastActive')) {
    header("Location: /authintosysadmin.php");
    die;
}
if ($WEBSESSION->get('sysAdminLastActive') + $CONFIG->sysAdminLogInTimeOutSeconds < TimeSource::time()) {
    header("Location: /authintosysadmin.php");
    die;
}
$WEBSESSION->set('sysAdminLastActive', \TimeSource::time());
///////////////////////////////////////////// APP
$app->before(function (Request $request) use($app) {
    global $CONFIG;
    # ////////////// Timezone
    $timezone = $CONFIG->sysAdminTimeZone;
    $app['twig']->addGlobal('currentTimeZone', $timezone);
    $app['currentTimeZone'] = $timezone;
});
require APP_ROOT_DIR . '/core/webSysAdmin/index.routes.php';
foreach ($CONFIG->extensions as $extensionName) {
    if (file_exists(APP_ROOT_DIR . '/extension/' . $extensionName . '/webSysAdmin/index.routes.php')) {
        require APP_ROOT_DIR . '/extension/' . $extensionName . '/webSysAdmin/index.routes.php';
    }
}
$app->run();
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:31,代码来源:index.php

示例7: isInPast

 public function isInPast()
 {
     return $this->end_at->getTimeStamp() < \TimeSource::time();
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:4,代码来源:EventModel.php

示例8: processFBData

 protected function processFBData($id, $fbData)
 {
     global $CONFIG;
     $start = new \DateTime($fbData['start_time'], new \DateTimeZone('UTC'));
     if ($fbData['end_time']) {
         $end = new \DateTime($fbData['end_time'], new \DateTimeZone('UTC'));
     } else {
         $end = clone $start;
     }
     if ($start && $end && $start <= $end) {
         if ($end->getTimeStamp() < \TimeSource::time()) {
             $this->countInPast++;
         } else {
             if ($start->getTimeStamp() > \TimeSource::time() + $CONFIG->importURLAllowEventsSecondsIntoFuture) {
                 $this->countToFarInFuture++;
             } else {
                 $importedEventRepo = new \repositories\ImportedEventRepository();
                 $importedEvent = $importedEventRepo->loadByImportURLIDAndImportId($this->importURLRun->getImportURL()->getId(), $id);
                 $changesToSave = false;
                 if (!$importedEvent) {
                     ++$this->countNew;
                     $importedEvent = new ImportedEventModel();
                     $importedEvent->setImportId($id);
                     $importedEvent->setImportUrlId($this->importURLRun->getImportURL()->getId());
                     $this->setImportedEventFromFBData($importedEvent, $fbData);
                     $changesToSave = true;
                 } else {
                     ++$this->countExisting;
                     $changesToSave = $this->setImportedEventFromFBData($importedEvent, $fbData);
                     // if was deleted, undelete
                     if ($importedEvent->getIsDeleted()) {
                         $importedEvent->setIsDeleted(false);
                         $changesToSave = true;
                     }
                 }
                 if ($changesToSave && $this->countSaved < $this->limitToSaveOnEachRun) {
                     ++$this->countSaved;
                     $this->importedEventsToEvents->addImportedEvent($importedEvent);
                     if ($importedEvent->getId()) {
                         if ($importedEvent->getIsDeleted()) {
                             $importedEventRepo->delete($importedEvent);
                         } else {
                             $importedEventRepo->edit($importedEvent);
                         }
                     } else {
                         $importedEventRepo->create($importedEvent);
                     }
                 }
             }
         }
     }
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:52,代码来源:ImportURLFacebookHandler.php

示例9: isGroupRunningOutOfFutureEvents

 /**
  * 
  * @return int|boolean  0= false, 1=warn, 2=out
  */
 public function isGroupRunningOutOfFutureEvents(GroupModel $group, SiteModel $site)
 {
     global $DB, $CONFIG;
     if (!$group) {
         return 0;
     }
     $stat = $DB->prepare("SELECT event_information.start_at FROM event_information " . " LEFT JOIN event_in_group ON event_in_group.event_id = event_information.id AND event_in_group.removed_at IS NULL " . "WHERE event_in_group.group_id =:id AND start_at > :start_at AND is_deleted = '0' " . "ORDER BY event_information.start_at DESC");
     $stat->execute(array('id' => $group->getId(), 'start_at' => \TimeSource::getFormattedForDataBase()));
     if ($stat->rowCount() > 0) {
         $data = $stat->fetch();
         $utc = new \DateTimeZone("UTC");
         $lastStartAt = new \DateTime($data['start_at'], $utc);
         $secondsToWarn = $site->getPromptEmailsDaysInAdvance() * 24 * 60 * 60;
         if ($lastStartAt->getTimestamp() < \TimeSource::time() + $secondsToWarn) {
             return 1;
         } else {
             return 0;
         }
     }
     return 2;
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:25,代码来源:GroupRepository.php

示例10: isShouldExpireNow

 public function isShouldExpireNow()
 {
     global $CONFIG;
     $r = new ImportURLRepository();
     $lastEdit = $r->getLastEditDateForImportURL($this);
     return $lastEdit->getTimeStamp() < \TimeSource::time() - $CONFIG->importURLExpireSecondsAfterLastEdit;
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:7,代码来源:ImportURLModel.php


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