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


PHP TimeSource::getDateTime方法代码示例

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


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

示例1: run

 protected function run()
 {
     $siteRepoBuilder = new SiteRepositoryBuilder();
     $siteRepoBuilder->setIsOpenBySysAdminsOnly(true);
     $countCheck = 0;
     $countSend = 0;
     foreach ($siteRepoBuilder->fetchAll() as $site) {
         $this->logVerbose("Site " . $site->getSlug());
         $userRepoBuilder = new UserAccountRepositoryBuilder();
         $userRepoBuilder->setIsOpenBySysAdminsOnly(true);
         foreach ($userRepoBuilder->fetchAll() as $userAccount) {
             $this->logVerbose("User " . $userAccount->getId());
             ++$countCheck;
             $checkTime = \TimeSource::getDateTime();
             $contentsToSend = array();
             foreach ($this->app['extensions']->getExtensionsIncludingCore() as $extension) {
                 $contentsToSend = array_merge($contentsToSend, $extension->getUserNotifyContents($site, $userAccount));
             }
             if ($contentsToSend) {
                 $this->logVerbose("Found contents!");
                 ++$countSend;
                 $this->makeSureHistoriesAreCorrect($contentsToSend);
                 $this->sendFor($site, $userAccount, $contentsToSend);
                 foreach ($contentsToSend as $contentToSend) {
                     $contentToSend->markNotificationSent($checkTime);
                 }
             } else {
                 $this->logVerbose("found nothing");
             }
         }
     }
     return array('result' => 'ok', 'countCheck' => $countCheck, 'countSend' => $countSend);
 }
开发者ID:schlos,项目名称:MeetYourNextMP-Web-Core,代码行数:33,代码来源:SendUserWatchesNotifyTask.php

示例2: __construct

 function __construct(BaseValueReport $report, \DateTime $start, $end = null, $timeperiod = "P1M")
 {
     $this->end = $end ? $end : \TimeSource::getDateTime();
     $this->report = $report;
     $this->start = $start;
     $this->timeperiod = $timeperiod;
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:7,代码来源:SeriesOfValueByTimeReport.php

示例3: build

 public function build()
 {
     // We only want events in X days before now and onwards
     $time = \TimeSource::getDateTime();
     $time->add(new \DateInterval("P" . $this->daysBefore . "D"));
     $this->eventRepositoryBuilder->setBefore($time);
     parent::build();
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:8,代码来源:EventListATOMBeforeBuilder.php

示例4: hasRunToday

 public function hasRunToday()
 {
     $start = \TimeSource::getDateTime();
     $start->setTime(0, 0, 0);
     $stat = $this->app['db']->prepare("SELECT ended_at FROM task_log " . "WHERE extension_id=:extension_id AND task_id=:task_id AND started_at > :started_at " . "ORDER BY ended_at DESC LIMIT 1");
     $stat->execute(array('extension_id' => $this->getExtensionId(), 'task_id' => $this->getTaskId(), 'started_at' => $start->format("Y-m-d H:i:s")));
     return $stat->rowCount() > 0;
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:8,代码来源:BaseTask.php

示例5: __construct

 public function __construct(SiteModel $site = null, $timeZone = null, $title = null)
 {
     parent::__construct($site, $timeZone, $title);
     // We go back a month, just so calendars have a bit of the past available.
     $time = \TimeSource::getDateTime();
     $time->sub(new \DateInterval("P30D"));
     $this->eventRepositoryBuilder->setAfter($time);
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:8,代码来源:EventListICalBuilder.php

示例6: calendarNow

 function calendarNow(Application $app)
 {
     $cal = new \RenderCalendar();
     $cal->getEventRepositoryBuilder()->setSite($app['currentSite']);
     $cal->getEventRepositoryBuilder()->setIncludeDeleted(false);
     if ($app['currentUser']) {
         $cal->getEventRepositoryBuilder()->setUserAccount($app['currentUser'], true);
     }
     $cal->byDate(\TimeSource::getDateTime(), 31, true);
     list($prevYear, $prevMonth, $nextYear, $nextMonth) = $cal->getPrevNextLinksByMonth();
     return $app['twig']->render('/site/calendarPage.html.twig', array('calendar' => $cal, 'prevYear' => $prevYear, 'prevMonth' => $prevMonth, 'nextYear' => $nextYear, 'nextMonth' => $nextMonth, 'pageTitle' => 'Calendar', 'showCurrentUserOptions' => true));
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:12,代码来源:EventListController.php

示例7: loadRecentlyUnusedSentForUserAccountId

 /**
  * 
  * @return \models\UserAccountResetModel A single one or NULL. Technically it may load multiple ones, but we only return one.
  */
 public function loadRecentlyUnusedSentForUserAccountId($id, $seconds = 60)
 {
     global $DB;
     $stat = $DB->prepare("SELECT user_account_reset.* FROM user_account_reset WHERE reset_at IS NULL AND user_account_id =:user_account_id AND created_at > :since");
     $time = \TimeSource::getDateTime();
     $time->setTimestamp($time->getTimestamp() - $seconds);
     $stat->execute(array('user_account_id' => $id, 'since' => $time->format('Y-m-d H:i:s')));
     if ($stat->rowCount() > 0) {
         $uar = new UserAccountResetModel();
         $uar->setFromDataBaseRow($stat->fetch());
         return $uar;
     }
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:17,代码来源:UserAccountResetRepository.php

示例8: calendarNow

 function calendarNow(Request $request, Application $app)
 {
     $this->parameters['calendar'] = new \RenderCalendar();
     $this->parameters['calendar']->getEventRepositoryBuilder()->setSite($app['currentSite']);
     $this->parameters['calendar']->getEventRepositoryBuilder()->setVenueVirtualOnly(true);
     $this->parameters['calendar']->getEventRepositoryBuilder()->setIncludeDeleted(false);
     if ($app['currentUser']) {
         $this->parameters['calendar']->getEventRepositoryBuilder()->setUserAccount($app['currentUser'], true);
         $this->parameters['showCurrentUserOptions'] = true;
     }
     $this->parameters['calendar']->byDate(\TimeSource::getDateTime(), 31, true);
     list($this->parameters['prevYear'], $this->parameters['prevMonth'], $this->parameters['nextYear'], $this->parameters['nextMonth']) = $this->parameters['calendar']->getPrevNextLinksByMonth();
     $this->parameters['pageTitle'] = "Virtual";
     $this->parameters['venueVirtual'] = true;
     return $app['twig']->render('/site/calendarPage.html.twig', $this->parameters);
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:16,代码来源:VenueVirtualController.php

示例9: calendarNow

 function calendarNow($slug, Request $request, Application $app)
 {
     if (!$this->build($slug, $request, $app)) {
         $app->abort(404, "Country does not exist.");
     }
     $this->parameters['calendar'] = new \RenderCalendar();
     $this->parameters['calendar']->getEventRepositoryBuilder()->setSite($app['currentSite']);
     $this->parameters['calendar']->getEventRepositoryBuilder()->setCountry($this->parameters['country']);
     $this->parameters['calendar']->getEventRepositoryBuilder()->setIncludeDeleted(false);
     if ($app['currentUser']) {
         $this->parameters['calendar']->getEventRepositoryBuilder()->setUserAccount($app['currentUser'], true);
         $this->parameters['showCurrentUserOptions'] = true;
     }
     $this->parameters['calendar']->byDate(\TimeSource::getDateTime(), 31, true);
     list($this->parameters['prevYear'], $this->parameters['prevMonth'], $this->parameters['nextYear'], $this->parameters['nextMonth']) = $this->parameters['calendar']->getPrevNextLinksByMonth();
     $this->parameters['pageTitle'] = $this->parameters['country']->getTitle();
     return $app['twig']->render('/site/calendarPage.html.twig', $this->parameters);
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:18,代码来源:CountryController.php

示例10: onThisStepProcessPage

 function onThisStepProcessPage()
 {
     if ($this->getCurrentMode() == $this->MODE_FREE) {
         if ($this->request->request->get('action') == 'startAndEndFreeText') {
             $this->draftEvent->setDetailsValue('event.start_end_freetext.start', \TimeSource::getDateTime());
             $this->draftEvent->setDetailsValue('event.start_end_freetext.end', \TimeSource::getDateTime());
             if ($this->request->request->get('startAndEndFreeText')) {
                 $parse = new ParseDateTimeRangeString(\TimeSource::getDateTime(), $this->application['currentTimeZone']);
                 $parseResult = $parse->parse($this->request->request->get('startAndEndFreeText'));
                 if ($parseResult->getStart()) {
                     $this->draftEvent->setDetailsValue('event.start_end_freetext.start', $parseResult->getStart());
                     // If no end is returned, just set start as sensible default
                     $this->draftEvent->setDetailsValue('event.start_end_freetext.end', $parseResult->getEnd() ? $parseResult->getEnd() : $parseResult->getStart());
                 }
             }
             $this->draftEvent->setDetailsValue('event.start_end_freetext.text', $this->request->request->get('startAndEndFreeText'));
             $this->draftEvent->setDetailsValue('event.start_end_freetext.done', 'yes');
             return true;
         }
     } else {
         if ('POST' == $this->request->getMethod()) {
             $this->form->bind($this->request);
             // Store these on object for JS
             $this->currentStart = $this->form->get('start_at')->getData();
             $this->currentEnd = $this->form->get('end_at')->getData();
             $this->currentTimeZone = $this->form->get('timezone')->getData();
             if ($this->form->isValid()) {
                 $this->draftEvent->setDetailsValue('event.start_at', $this->form->get('start_at')->getData());
                 $this->draftEvent->setDetailsValue('event.end_at', $this->form->get('end_at')->getData());
                 $this->draftEvent->setDetailsValue('event.country_id', $this->form->get('country_id')->getData());
                 $this->draftEvent->setDetailsValue('event.timezone', $this->form->get('timezone')->getData());
                 $this->isAllInformationGathered = true;
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:38,代码来源:NewEventWhenDetails.php

示例11: buildEvents

 public function buildEvents(Application $app)
 {
     global $CONFIG;
     $repo = new SiteRepository();
     $site = $repo->loadById($this->site_id);
     $start = \TimeSource::getDateTime();
     $end = \TimeSource::getDateTime();
     $end->add(new \DateInterval("P" . ($this->days_into_future + 1) . "D"));
     $calendar = new \RenderCalendar();
     $calendar->setStartAndEnd($start, $end);
     $calendar->getEventRepositoryBuilder()->setSite($site);
     $calendar->getEventRepositoryBuilder()->setIncludeDeleted(true);
     $calData = $calendar->getData();
     $this->events = $calendar->getEvents();
     $this->event_text = $app['twig']->render('email/sendemail.eventview.calendar.txt.twig', array('data' => $calData, 'currentSite' => $site));
     if ($CONFIG->isDebug) {
         file_put_contents('/tmp/sendemail.eventview.calendar.txt', $this->event_text);
     }
     $this->event_html = $app['twig']->render('email/sendemail.eventview.calendar.html.twig', array('data' => $calData, 'currentSite' => $site));
     if ($CONFIG->isDebug) {
         file_put_contents('/tmp/sendemail.eventview.calendar.html', $this->event_html);
     }
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:23,代码来源:SendEmailModel.php

示例12: buildForm

 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $crb = new CountryRepositoryBuilder();
     $crb->setSiteIn($this->site);
     $this->defaultCountry = null;
     $defaultCountryID = null;
     $countries = $crb->fetchAll();
     if (count($countries) > 1) {
         $countriesForSelect = array();
         foreach ($countries as $country) {
             $countriesForSelect[$country->getId()] = $country->getTitle();
             if ($this->defaultCountry == null && in_array($this->timeZoneName, $country->getTimezonesAsList())) {
                 $this->defaultCountry = $country;
                 $defaultCountryID = $country->getId();
             }
         }
         $builder->add('country_id', 'choice', array('label' => 'Country', 'choices' => $countriesForSelect, 'required' => true, 'data' => $defaultCountryID));
     } else {
         if (count($countries) == 1) {
             $this->defaultCountry = $countries[0];
             $builder->add('country_id', 'hidden', array('data' => $this->defaultCountry->getId()));
         }
     }
     $timezones = array();
     // Must explicetly set name as key otherwise Symfony forms puts an ID in, and that's no good for processing outside form
     foreach ($this->site->getCachedTimezonesAsList() as $timezone) {
         $timezones[$timezone] = $timezone;
     }
     if (count($timezones) != 1) {
         $builder->add('timezone', 'choice', array('label' => 'Time Zone', 'choices' => $timezones, 'required' => true));
     } else {
         $timezone = array_pop($timezones);
         $builder->add('timezone', 'hidden', array('data' => $timezone));
     }
     $years = array(date('Y'), date('Y') + 1);
     $data = null;
     if ($this->eventDraft->hasDetailsValue('event.start_at')) {
         $data = $this->eventDraft->getDetailsValueAsDateTime('event.start_at');
     } else {
         if ($this->eventDraft->hasDetailsValue('event.start_end_freetext.start')) {
             $data = $this->eventDraft->getDetailsValueAsDateTime('event.start_end_freetext.start');
         } else {
             if ($this->eventDraft->hasDetailsValue('incoming.event.start_at')) {
                 $data = $this->eventDraft->getDetailsValueAsDateTime('incoming.event.start_at');
             }
         }
     }
     $startOptions = array('label' => 'Start', 'date_widget' => 'single_text', 'date_format' => 'd/M/y', 'model_timezone' => 'UTC', 'view_timezone' => $this->timeZoneName, 'years' => $years, 'attr' => array('class' => 'dateInput'), 'required' => true, 'data' => $data);
     if ($this->formWidgetTimeMinutesMultiples > 1) {
         $startOptions['minutes'] = array();
         for ($i = 0; $i <= 59; $i = $i + $this->formWidgetTimeMinutesMultiples) {
             $startOptions['minutes'][] = $i;
         }
     }
     $builder->add('start_at', 'datetime', $startOptions);
     $data = null;
     if ($this->eventDraft->hasDetailsValue('event.end_at')) {
         $data = $this->eventDraft->getDetailsValueAsDateTime('event.end_at');
     } else {
         if ($this->eventDraft->hasDetailsValue('event.start_end_freetext.end')) {
             $data = $this->eventDraft->getDetailsValueAsDateTime('event.start_end_freetext.end');
         } else {
             if ($this->eventDraft->hasDetailsValue('incoming.event.end_at')) {
                 $data = $this->eventDraft->getDetailsValueAsDateTime('incoming.event.end_at');
             }
         }
     }
     $endOptions = array('label' => 'End', 'date_widget' => 'single_text', 'date_format' => 'd/M/y', 'model_timezone' => 'UTC', 'view_timezone' => $this->timeZoneName, 'years' => $years, 'attr' => array('class' => 'dateInput'), 'required' => true, 'data' => $data);
     if ($this->formWidgetTimeMinutesMultiples > 1) {
         $endOptions['minutes'] = array();
         for ($i = 0; $i <= 59; $i = $i + $this->formWidgetTimeMinutesMultiples) {
             $endOptions['minutes'][] = $i;
         }
     }
     $builder->add('end_at', 'datetime', $endOptions);
     /** @var \closure $myExtraFieldValidator **/
     $myExtraFieldValidator = function (FormEvent $event) {
         global $CONFIG;
         $form = $event->getForm();
         $myExtraFieldStart = $form->get('start_at')->getData();
         $myExtraFieldEnd = $form->get('end_at')->getData();
         // Validate end is after start?
         if ($myExtraFieldStart > $myExtraFieldEnd) {
             $form['start_at']->addError(new FormError("The start can not be after the end!"));
         }
         // validate not to far in future
         $max = \TimeSource::getDateTime();
         $max->add(new \DateInterval("P" . $CONFIG->eventsCantBeMoreThanYearsInFuture . "Y"));
         if ($myExtraFieldStart > $max) {
             $form['start_at']->addError(new FormError("The event can not be more than " . ($CONFIG->eventsCantBeMoreThanYearsInFuture > 1 ? $CONFIG->eventsCantBeMoreThanYearsInFuture . " years" : "a year") . " in the future."));
         }
         if ($myExtraFieldEnd > $max) {
             $form['end_at']->addError(new FormError("The event can not be more than " . ($CONFIG->eventsCantBeMoreThanYearsInFuture > 1 ? $CONFIG->eventsCantBeMoreThanYearsInFuture . " years" : "a year") . " in the future."));
         }
         // validate not to far in past
         $min = \TimeSource::getDateTime();
         $min->sub(new \DateInterval("P" . $CONFIG->eventsCantBeMoreThanYearsInPast . "Y"));
         if ($myExtraFieldStart < $min) {
             $form['start_at']->addError(new FormError("The event can not be more than " . ($CONFIG->eventsCantBeMoreThanYearsInPast > 1 ? $CONFIG->eventsCantBeMoreThanYearsInPast . " years" : "a year") . " in the past."));
         }
//.........这里部分代码省略.........
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:101,代码来源:EventNewWhenDetailsForm.php

示例13: calendarNow

 function calendarNow(Application $app)
 {
     $cal = new \RenderCalendar();
     $params = new EventFilterParams($cal->getEventRepositoryBuilder());
     $params->setHasDateControls(false);
     $params->setSpecifiedUserControls(true, $app['currentUser'], true);
     $params->set($_GET);
     $cal->byDate(\TimeSource::getDateTime(), 31, true);
     list($prevYear, $prevMonth, $nextYear, $nextMonth) = $cal->getPrevNextLinksByMonth();
     return $app['twig']->render('/index/currentuser/calendar.html.twig', array('calendar' => $cal, 'eventListFilterParams' => $params, 'prevYear' => $prevYear, 'prevMonth' => $prevMonth, 'nextYear' => $nextYear, 'nextMonth' => $nextMonth, 'showCurrentUserOptions' => true));
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:11,代码来源:CurrentUserController.php

示例14: setAfterNow

 public function setAfterNow()
 {
     $this->after = \TimeSource::getDateTime();
     return $this;
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:5,代码来源:ImportedEventRepositoryBuilder.php

示例15: getPromptEmailData

 public function getPromptEmailData(SiteModel $site, EventModel $lastEvent = null)
 {
     global $CONFIG;
     $moreEventsNeeded = false;
     $checkTime = \TimeSource::getDateTime();
     if ($lastEvent) {
         $dateInterval = new \DateInterval("P" . $site->getPromptEmailsDaysInAdvance() . "D");
         $endTimeMinusExtra = clone $lastEvent->getEndAt();
         $endTimeMinusExtra->sub($dateInterval);
         if ($endTimeMinusExtra < $checkTime) {
             // there is a last event and it is before now plus whenever!
             // Now check; have we notified the user of this before?
             $dateSince = $this->getSinceDateForPromptChecking();
             if ($endTimeMinusExtra > $dateSince) {
                 // Finally check: has safe gap passed where we only send one email every X days?
                 $safeGapDays = max($site->getPromptEmailsDaysInAdvance(), $CONFIG->userWatchesPromptEmailSafeGapDays);
                 $nowMinusSafeGap = \TimeSource::getDateTime();
                 $nowMinusSafeGap->sub(new \DateInterval("P" . $safeGapDays . "D"));
                 if ($dateSince < $nowMinusSafeGap) {
                     // Finally we can agree to send an alert!
                     $moreEventsNeeded = true;
                 }
             }
         }
     }
     // TODO when add importing, need to double check this.
     return array('moreEventsNeeded' => $moreEventsNeeded, 'checkTime' => $checkTime);
 }
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:28,代码来源:UserWatchesAreaModel.php


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