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


PHP Zend_Date::addHour方法代码示例

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


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

示例1: save

 public function save(Default_Model_Pastebin $pastebin)
 {
     $shortId = $pastebin->getShortId();
     if (empty($shortId)) {
         $shortId = $this->_getShortId();
         $pastebin->setShortId($shortId);
     }
     $name = $pastebin->getName();
     $expiresTime = $pastebin->getExpires();
     $expires = null;
     if ($expiresTime != 'never') {
         $expires = new Zend_Date();
         if ($expiresTime == 'hour') {
             $expires->addHour(1);
         }
         if ($expiresTime == 'day') {
             $expires->addDay(1);
         }
         if ($expiresTime == 'week') {
             $expires->addWeek(1);
         }
         if ($expiresTime == 'month') {
             $expires->addMonth(1);
         }
         $expires = $expires->get('yyyy-MM-dd HH:mm:ss');
     }
     $data = array('short_id' => $shortId, 'name' => !empty($name) ? $name : 'Anonymous', 'code' => $pastebin->getCode(), 'language' => $pastebin->getLanguage(), 'expires' => $expires, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'created' => date('Y-m-d H:i:s'));
     if (null === ($id = $pastebin->getId())) {
         unset($data['id']);
         $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('id = ?' => $id));
     }
     return $shortId;
 }
开发者ID:sebflipper,项目名称:zf-pastebin,代码行数:35,代码来源:PastebinMapper.php

示例2: execute

 public function execute($lastRunDt = null)
 {
     $config = Zend_Registry::get('config');
     $checkDtStart = new Zend_Date($this->_lastRunDt);
     $checkDtStart->subHour($config->user->numHoursEvaluationReminder->val);
     $checkDtEnd = new Zend_Date();
     $checkDtEnd->subHour($config->user->numHoursEvaluationReminder->val);
     $event = new Event();
     $events = $event->getEvents(null, null, null, $checkDtStart->getTimestamp(), $checkDtEnd->getTimestamp(), 'open');
     $location = new Location();
     $workshop = new Workshop();
     $instructor = new Event_Instructor();
     $attendee = new Event_Attendee();
     $eu = new Evaluation_User();
     foreach ($events as $e) {
         $startDt = strtotime($e->date . ' ' . $e->startTime);
         $endDt = strtotime($e->date . ' ' . $e->endTime);
         if ($checkDtStart->getTimestamp() < $endDt && $checkDtEnd->getTimestamp() >= $endDt) {
             $evalAvailableDt = new Zend_Date($endDt);
             $evalAvailableDt->addHour($config->user->numHoursEvaluationAvailability->val);
             if ($evalAvailableDt->getTimestamp() > time()) {
                 $taken = $eu->getCompleted($e->eventId);
                 $thisLocation = $location->find($e->locationId);
                 if (is_null($thisLocation)) {
                     throw new Ot_Exception_Data('msg-error-noLocation');
                 }
                 $thisWorkshop = $workshop->find($e->workshopId);
                 if (is_null($thisWorkshop)) {
                     throw new Ot_Exception_Data('msg-error-noWorkshop');
                 }
                 $instructors = $instructor->getInstructorsForEvent($e->eventId);
                 $instructorNames = array();
                 $instructorEmails = array();
                 foreach ($instructors as $i) {
                     $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
                     $instructorEmails[] = $i['emailAddress'];
                 }
                 $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
                 $attending = $attendee->getAttendeesForEvent($e->eventId, 'attending');
                 foreach ($attending as $a) {
                     if ($a['attended'] == 1 && !in_array($a['accountId'], $taken)) {
                         $trigger = new Ot_Trigger();
                         $trigger->setVariables($data);
                         $trigger->accountId = $a['accountId'];
                         $trigger->studentEmail = $a['emailAddress'];
                         $trigger->studentName = $a['firstName'] . ' ' . $a['lastName'];
                         $trigger->studentUsername = $a['username'];
                         $trigger->dispatch('Event_Evaluation_Reminder');
                     }
                 }
             }
         }
     }
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:54,代码来源:WorkshopEvaluationReminder.php

示例3: _getDate

 protected function _getDate($timeAmount, Zend_Date $date)
 {
     $nowDate = new Zend_Date();
     $dateWithTimeAmount = $date->addHour($timeAmount);
     if ($timeAmount == 0) {
         $date = $date->addMinute(1);
     } elseif ($timeAmount < 0 && $nowDate->isLater($dateWithTimeAmount)) {
         $date = $nowDate->addMinute(1);
     } else {
         $date = $dateWithTimeAmount;
     }
     return $date;
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:13,代码来源:Alert.php

示例4: getDateRange

 public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
 {
     $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
     $dateStart = clone $dateEnd;
     // go to the end of a day
     $dateEnd->setHour(23);
     $dateEnd->setMinute(59);
     $dateEnd->setSecond(59);
     $dateStart->setHour(0);
     $dateStart->setMinute(0);
     $dateStart->setSecond(0);
     switch ($range) {
         case '24h':
             $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $dateEnd->addHour(1);
             $dateStart = clone $dateEnd;
             $dateStart->subDay(1);
             break;
         case '7d':
             // substract 6 days we need to include
             // only today and not hte last one from range
             $dateStart->subDay(6);
             break;
         case '1m':
             $dateStart->setDay(Mage::getStoreConfig('reports/dashboard/mtd_start'));
             break;
         case 'custom':
             $dateStart = $customStart ? $customStart : $dateEnd;
             $dateEnd = $customEnd ? $customEnd : $dateEnd;
             break;
         case '1y':
         case '2y':
             $startMonthDay = explode(',', Mage::getStoreConfig('reports/dashboard/ytd_start'));
             $startMonth = isset($startMonthDay[0]) ? (int) $startMonthDay[0] : 1;
             $startDay = isset($startMonthDay[1]) ? (int) $startMonthDay[1] : 1;
             $dateStart->setMonth($startMonth);
             $dateStart->setDay($startDay);
             if ($range == '2y') {
                 $dateStart->subYear(1);
             }
             break;
     }
     if ($returnObjects) {
         return array($dateStart, $dateEnd);
     } else {
         return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
     }
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:48,代码来源:Collection.php

示例5: getDateRange

 public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
 {
     $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
     $dateStart = clone $dateEnd;
     // go to the end of a day
     $dateEnd->setHour(23);
     $dateEnd->setMinute(59);
     $dateEnd->setSecond(59);
     $dateStart->setHour(0);
     $dateStart->setMinute(0);
     $dateStart->setSecond(0);
     switch ($range) {
         case '24h':
             $dateEnd = new Zend_Date(Mage::getModel('core/date')->gmtTimestamp());
             $dateEnd->addHour(1);
             $dateStart = clone $dateEnd;
             $dateStart->subDay(1);
             break;
         case '7d':
             // substract 6 days we need to include
             // only today and not hte last one from range
             $dateStart->subDay(6);
             break;
         case '1m':
             $dateStart->setDay(1);
             break;
         case 'custom':
             $dateStart = $customStart ? $customStart : $dateEnd;
             $dateEnd = $customEnd ? $customEnd : $dateEnd;
             break;
         case '1y':
             $dateStart->setMonth(1);
             $dateStart->setDay(1);
             break;
         case '2y':
             $dateStart->setMonth(1);
             $dateStart->setDay(1);
             $dateStart->subYear(1);
             break;
     }
     if ($returnObjects) {
         return array($dateStart, $dateEnd);
     } else {
         return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
     }
 }
开发者ID:jauderho,项目名称:magento-mirror,代码行数:46,代码来源:Collection.php

示例6: execute

 public function execute($lastRunDt = null)
 {
     $config = Zend_Registry::get('config');
     $event = new Event();
     $events = $event->getEvents(null, null, null, time(), null, 'open');
     $location = new Location();
     $workshop = new Workshop();
     $instructor = new Event_Instructor();
     $checkDt = new Zend_Date($this->_lastRunDt);
     $checkDt->addHour($config->user->numHoursLowAttendanceNotification->val);
     foreach ($events as $e) {
         if ($e->roleSize < $e->minSize) {
             $startDt = strtotime($e->date . ' ' . $e->startTime);
             $endDt = strtotime($e->date . ' ' . $e->endTime);
             if ($checkDt->getTimestamp() > $startDt && $this->_lastRunDt < $startDt) {
                 $thisLocation = $location->find($e->locationId);
                 if (is_null($thisLocation)) {
                     throw new Ot_Exception_Data('msg-error-noLocation');
                 }
                 $thisWorkshop = $workshop->find($e->workshopId);
                 if (is_null($thisWorkshop)) {
                     throw new Ot_Exception_Data('msg-error-noWorkshop');
                 }
                 $instructors = $instructor->getInstructorsForEvent($e->eventId);
                 $instructorNames = array();
                 $instructorEmails = array();
                 foreach ($instructors as $i) {
                     $instructorNames[] = $i['firstName'] . ' ' . $i['lastName'];
                     $instructorEmails[] = $i['emailAddress'];
                 }
                 $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails));
                 $trigger = new Ot_Trigger();
                 $trigger->setVariables($data);
                 $trigger->dispatch('Event_LowAttendance');
             }
         }
     }
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:38,代码来源:WorkshopSignupLowAttendance.php

示例7: testLoose


//.........这里部分代码省略.........
         // success
     }
     try {
         $date->setDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
开发者ID:jsnshrmn,项目名称:Suma,代码行数:67,代码来源:DateTest.php

示例8: baseInit

 public function baseInit()
 {
     $dict = new Base_Dictionary();
     $date = new Zend_Date();
     $user = Zend_Auth::getInstance()->getIdentity();
     $client = Logic_Client::getInstance();
     $wsServiceSet = $client->getGroupListAsDict(Wsclient::GROUP_SERVICE_SET);
     $config = Zend_Registry::get('config');
     $this->addElement('text', 'name', array('required' => true, 'label' => 'Nazwa wysyłki'));
     $this->datee(false, "send_start", "Początek wysyłki");
     $this->send_start->setValue($date->getDate()->toString('YYYY-MM-dd'))->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date2 = clone $date;
         return $date->getTimestamp() <= $date2->setDate($value, 'YYYY-MM-dd')->getTimestamp();
     }));
     $this->timee(false, "time_send_start", "Okno czasowe od");
     $this->time_send_start->setValue('8:00');
     $this->timee(false, "time_send_end", "Okno czasowe do");
     $this->time_send_end->setValue('20:00');
     $this->time_send_end->addValidator('Callback', false, array('callback' => function ($value) {
         return strtotime($value) > strtotime($this->time_send_start->getValue());
     }));
     $this->datetimee(false, 'expiry_date', "Ważność wiadomości", false, array('value' => ''));
     $this->expiry_date->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date2->setDate($value, 'YYYY-MM-dd HH:mm');
         $date->setDate($this->send_start->getValue(), 'YYYY-MM-dd HH:mm');
         return $date->getTimestamp() <= $date2->getTimestamp() && $date->addHour(72)->getTimestamp() >= $date2->getTimestamp();
     }));
     $this->expiry_date->getValidator('Callback')->setMessages(array(Zend_Validate_Callback::INVALID_VALUE => "Data ważności wiadmości może wynosić maksymalnie 72 godziny"));
     $this->addElement('checkbox', 'repeat_message', array('label' => 'Powtarzaj tą wiadomość', 'attribs' => array('onchange' => 'checkPackageOptions();')));
     $this->repeat_message->addValidator('Callback', false, array('callback' => function ($value) {
         if ($value) {
             $this->repeat_interval->setRequired(true);
             $this->repeat_count->setRequired(true);
             $this->repeat_end->setRequired(true);
         }
         return true;
     }));
     $this->addElement('radio', 'repeat_interval', array('MultiOptions' => $dict->setSource('package_repeat')->getDictionary(), 'attribs' => array('disable' => 'disable'), 'attribs' => array('onchange' => 'checkPackageOptions();')));
     $this->repeat_interval->addValidator('Callback', false, array('callback' => function ($value) {
         if ($value == 5) {
             $this->repeat_days->setRequired(true);
         } elseif ($value == 4) {
             $this->repeat_day_interval->setRequired(true);
         }
         return true;
     }));
     $this->addElement('multiselect', 'repeat_days', array('MultiOptions' => $dict->setSource('day_of_week')->getDictionary(), 'attribs' => array('disable' => 'disable')));
     $this->addElement('text', 'repeat_day_interval', array('label' => 'Powtarzań wiadomość co (liczba dni)', 'attribs' => array('disable' => 'disable')));
     $this->addElement('text', 'repeat_count', array('label' => 'Ilość powtórzeń wiadomości', 'attribs' => array('disable' => 'disable')));
     $this->datetimee(false, "repeat_end", "Powtarzań do", false, array('value' => '', 'attribs' => array('disabled' => 'disabled')));
     $this->repeat_end->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date->setDate($value, 'YYYY-MM-dd HH:mm');
         $date2->setDate($this->send_start->getValue(), 'YYYY-MM-dd HH:mm');
         return $date->getTimestamp() <= $date2->setDate($value, 'YYYY-MM-dd HH:mm')->getTimestamp();
     }));
     $this->addElement('select', 'ws_service_set_id', array('label' => 'Wysyłka', 'required' => true, 'MultiOptions' => $this->addClearStart($wsServiceSet), 'attribs' => array('onchange' => 'getServiceSetOptions();')));
     $this->addElement('select', 'file_type', array('required' => true, 'label' => 'Typ wysyłki:', 'multioptions' => $this->addClearStart($dict->setSource('service_import_file_type')->getDictionary())));
     $this->addElement('file', 'addressbook_import_csv', array('label' => 'CSV z listą kontaktów do zaimportowania', 'decorators' => $this->_fileDecorator, 'validators' => array(array('Extension', false, 'csv'), array('Size', false, $config['uploads']['maxfilesize']))));
     $this->addElement('select', 'delimeter', array('label' => "Separator pola", 'MultiOptions' => $this->addClearStart($dict->setSource('csv_delimeter')->getDictionary())));
     $this->addElement('select', 'phone_heders', array('label' => "Kolumna z kontaktami"));
     $this->addElement('select', 'ws_addressbook_id', array('label' => 'Adresy', 'MultiOptions' => $this->addClearStart($dict->setSource(new Addressbook(), array('created_by =' . (int) $user->id, 'ghost=false'), 'id', 'id', array('addressbook_name'))->getDictionary())));
     $this->addDisplayGroup(array($this->addressbook_import_csv, $this->delimeter, $this->phone_heders), 'tags_import');
     $this->addElement('select', 'message_heders', array('label' => "Kolumna z wiadomością"));
     $this->submit(false, 'save_send', 'Wyślij');
     $this->submit();
     $this->cancel();
 }
开发者ID:knatorski,项目名称:SMS,代码行数:72,代码来源:Generic.php

示例9: getEventsForUser

 public function getEventsForUser($accountId)
 {
     $config = Zend_Registry::get('config');
     $attendee = new Event_Attendee();
     $instructor = new Event_Instructor();
     $location = new Location();
     $document = new Workshop_Document();
     $account = new Ot_Account();
     $eu = new Evaluation_User();
     $stayOpen = new Zend_Date();
     $stayOpen->subHour($config->user->numHoursEvaluationAvailability->val);
     $locationCache = array();
     $reservations = $attendee->getEventsForAttendee($accountId);
     $time = time();
     foreach ($reservations as &$r) {
         $r['active'] = false;
         // we determine if the class is open
         $startDt = new Zend_Date(strtotime($r['date'] . ' ' . $r['startTime']));
         $endDt = new Zend_Date(strtotime($r['date'] . ' ' . $r['endTime']));
         $endDt->addHour($config->user->numHoursEvaluationAvailability->val);
         $r['evaluatable'] = $this->isEvaluatable($r['eventId']);
         // checks to see if its possible that the class is open for evaluation
         if ($r['evaluatable'] && !$eu->hasCompleted($accountId, $r['eventId'])) {
             $r['active'] = true;
         } elseif ($startDt->getTimestamp() > $time) {
             $r['active'] = true;
         }
         $r = array_merge(array('startDt' => $startDt->getTimestamp()), $r);
         $r['hasHandouts'] = false;
         $documents = $document->getDocumentsForWorkshop($r['workshopId']);
         if (count($documents) > 0) {
             $r['hasHandouts'] = true;
         }
         $r['cancelable'] = false;
         if ($r['active']) {
             $startDt->subHour($config->user->numHoursEventCancel->val);
             $r['cancelable'] = $startDt->getTimestamp() > $time;
             if ($r['status'] == 'waitlist') {
                 $waiting = $attendee->getAttendeesForEvent($r['eventId'], 'waitlist');
                 $position = 1;
                 foreach ($waiting as $w) {
                     if ($accountId == $w['accountId']) {
                         break;
                     }
                     $position++;
                 }
                 $r['waitlistPosition'] = $position;
             }
         }
     }
     // Get presently taught classes
     $teaching = $instructor->getEventsForInstructor($accountId);
     foreach ($teaching as &$t) {
         $startDt = new Zend_Date(strtotime($t['date'] . ' ' . $t['startTime']));
         $endDt = new Zend_Date(strtotime($t['date'] . ' ' . $t['endTime']));
         $endDt->addHour($config->user->numHoursEvaluationAvailability->val);
         $t = array_merge(array('startDt' => $startDt->getTimestamp()), $t);
         $t['active'] = false;
         // checks to see if its possible that the class is open for evaluation
         if ($endDt->getTimestamp() > $time) {
             $t['active'] = true;
         }
         $t['status'] = 'instructor';
     }
     $events = array_merge($reservations, $teaching);
     // sort by event order
     $eDates = array();
     foreach ($events as $key => $value) {
         $eDates[$key] = $value['startDt'];
     }
     asort($eDates);
     $newEvents = array();
     foreach (array_keys($eDates) as $key) {
         $newEvents[] = $events[$key];
     }
     $events = $newEvents;
     $currentEvents = array();
     $pastEvents = array();
     foreach ($events as $e) {
         $where = $instructor->getAdapter()->quoteInto('eventId = ?', $e['eventId']);
         $instructors = $instructor->fetchAll($where);
         $instructorIds = array();
         foreach ($instructors as $i) {
             $instructorIds[] = $i->accountId;
         }
         if (count($instructorIds) != 0) {
             $accounts = $account->fetchAll($account->getAdapter()->quoteInto('accountId IN (?)', $instructorIds), array('lastName', 'firstName'));
             foreach ($accounts as $a) {
                 $e['instructors'][] = $a->firstName . ' ' . $a->lastName;
             }
         }
         if (isset($locationCache[$e['locationId']])) {
             $e['location'] = $locationCache[$e['locationId']];
         } else {
             $thisLocation = $location->find($e['locationId']);
             if (is_null($thisLocation)) {
                 throw new Ot_Exception_Data('Location not found');
             }
             $e['location'] = $thisLocation->toArray();
             $locationCache[$e['locationId']] = $e['location'];
//.........这里部分代码省略.........
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:101,代码来源:Event.php


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