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


PHP Horde_Date::compareDate方法代码示例

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


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

示例1: getRecords

 /**
  * Search the database for call detail records, taking permissions into
  * consideration.
  *
  * @return array  [0] contains summary statistics; [1] is an array of the
  *                actual call records.
  * @throws Operator_Exception
  */
 public function getRecords($start, $end, $accountcode = null, $dcontext = null, $rowstart = 0, $rowlimit = 100)
 {
     // Start Date
     if (!is_a($start, 'Horde_Date')) {
         $start = new Horde_Date($start);
     }
     // End Date
     if (!is_a($end, 'Horde_Date')) {
         $end = new Horde_Date($end);
     }
     if ($start->compareDate($end) > 0) {
         throw new Operator_Exception(_("\"Start\" date must be on or before \"End\" date."));
     }
     if (empty($accountcode) || $accountcode == '%') {
         $permentry = 'operator:accountcodes';
     } else {
         $permentry = 'operator:accountcodes:' . $accountcode;
     }
     $perms = $GLOBALS['injector']->getInstance('Horde_Perms');
     if ($GLOBALS['registry']->isAdmin() || $perms->hasPermission('operator:accountcodes', $GLOBALS['registry']->getAuth(), Horde_Perms::READ) || $perms->hasPermission($permentry, $GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
         return $this->_getRecords($start, $end, $accountcode, $dcontext, $rowstart, $rowlimit);
     }
     throw new Operator_Exception(_("You do not have permission to view call detail records for that account code."));
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:32,代码来源:Driver.php

示例2: getTimeRange

 /**
  * @return string  The time range of the event ("All Day", "1:00pm-3:00pm",
  *                 "08:00-22:00").
  */
 public function getTimeRange()
 {
     if ($this->isAllDay()) {
         return _("All day");
     } elseif (($cmp = $this->start->compareDate($this->end)) > 0) {
         $df = $GLOBALS['prefs']->getValue('date_format');
         if ($cmp > 0) {
             return $this->end->strftime($df) . '-' . $this->start->strftime($df);
         } else {
             return $this->start->strftime($df) . '-' . $this->end->strftime($df);
         }
     } else {
         $twentyFour = $GLOBALS['prefs']->getValue('twentyFour');
         return $this->start->format($twentyFour ? 'G:i' : 'g:ia') . '-' . $this->end->format($twentyFour ? 'G:i' : 'g:ia');
     }
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:20,代码来源:Event.php

示例3: _getEvents

 private function _getEvents($dh, $startDate, $endDate)
 {
     $events = array();
     for ($date = new Horde_Date($startDate); $date->compareDate($endDate) <= 0; $date->mday++) {
         $holidays = $dh->getHolidayForDate($date->format('Y-m-d'), null, true);
         if (Date_Holidays::isError($holidays)) {
             Horde::log(sprintf('Unable to retrieve list of holidays from %s to %s', (string) $startDate, (string) $endDate), __FILE__, __LINE__);
             continue;
         }
         if (is_null($holidays)) {
             continue;
         }
         foreach ($holidays as $holiday) {
             $event = new Kronolith_Event_Holidays($this, $holiday);
             $events[] = $event;
         }
     }
     return $events;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:19,代码来源:Holidays.php

示例4: childrenOverdue

 /**
  * Returns whether any tasks in the list are overdue.
  *
  * @return boolean  True if any task or sub tasks are overdue.
  */
 public function childrenOverdue()
 {
     if (!empty($this->due)) {
         $due = new Horde_Date($this->due);
         if ($due->compareDate(new Horde_Date(time())) <= 0) {
             return true;
         }
     }
     foreach ($this->children as $task) {
         if ($task->childrenOverdue()) {
             return true;
         }
     }
     return false;
 }
开发者ID:GenerationLabs,项目名称:horde,代码行数:20,代码来源:Task.php

示例5: listTimeObjects

 /**
  * Returns a list of birthday or anniversary hashes from this source for a
  * certain period.
  *
  * @param Horde_Date $start  The start date of the valid period.
  * @param Horde_Date $end    The end date of the valid period.
  * @param string $category   The timeObjects category to return.
  *
  * @return array  A list of timeObject hashes.
  * @throws Turba Exception
  */
 public function listTimeObjects(Horde_Date $start, Horde_Date $end, $category)
 {
     try {
         $res = $this->getTimeObjectTurbaList($start, $end, $category);
     } catch (Turba_Exception $e) {
         /* Try the default implementation before returning an error */
         $res = $this->_getTimeObjectTurbaListFallback($start, $end, $category);
     }
     $t_objects = array();
     while ($ob = $res->next()) {
         $t_object = $ob->getValue($category);
         if (empty($t_object)) {
             continue;
         }
         try {
             $t_object = new Horde_Date($t_object);
         } catch (Horde_Date_Exception $e) {
             continue;
         }
         if ($t_object->compareDate($end) > 0) {
             continue;
         }
         $t_object_end = new Horde_Date($t_object);
         ++$t_object_end->mday;
         $key = $ob->getValue('__key');
         // Calculate the age of the time object
         if ($start->year == $end->year || $end->year == 9999) {
             $age = $start->year - $t_object->year;
         } elseif ($t_object->month <= $end->month) {
             // t_object must be in later year
             $age = $end->year - $t_object->year;
         } else {
             // t_object must be in earlier year
             $age = $start->year - $t_object->year;
         }
         $title = sprintf(_("%d. %s of %s"), $age, $GLOBALS['attributes'][$category]['label'], $ob->getValue('name'));
         $t_objects[] = array('id' => $key, 'title' => $title, 'start' => sprintf('%d-%02d-%02dT00:00:00', $t_object->year, $t_object->month, $t_object->mday), 'end' => sprintf('%d-%02d-%02dT00:00:00', $t_object_end->year, $t_object_end->month, $t_object_end->mday), 'recurrence' => array('type' => Horde_Date_Recurrence::RECUR_YEARLY_DATE, 'interval' => 1), 'params' => array('source' => $this->_name, 'key' => $key), 'link' => Horde::url('contact.php', true)->add(array('source' => $this->_name, 'key' => $key))->setRaw(true));
     }
     return $t_objects;
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:51,代码来源:Driver.php

示例6: addCoverDates

 /**
  * Adds an event to all the days it covers.
  *
  * @param array $result           The current result list.
  * @param Kronolith_Event $event  An event object.
  * @param Horde_Date $eventStart  The event's start at the actual
  *                                recurrence.
  * @param Horde_Date $eventEnd    The event's end at the actual recurrence.
  * @param boolean $json           Store the results of the events' toJson()
  *                                method?
  */
 public static function addCoverDates(&$results, $event, $eventStart, $eventEnd, $json)
 {
     $loopDate = new Horde_Date($eventStart->year, $eventStart->month, $eventStart->mday);
     $allDay = $event->isAllDay();
     while ($loopDate->compareDateTime($eventEnd) <= 0) {
         if (!$allDay || $loopDate->compareDateTime($eventEnd) != 0) {
             $addEvent = clone $event;
             $addEvent->start = $eventStart;
             $addEvent->end = $eventEnd;
             if ($loopDate->compareDate($eventStart) != 0) {
                 $addEvent->first = false;
             }
             if ($loopDate->compareDate($eventEnd) != 0) {
                 $addEvent->last = false;
             }
             if ($addEvent->recurs() && $addEvent->recurrence->hasCompletion($loopDate->year, $loopDate->month, $loopDate->mday)) {
                 $addEvent->status = Kronolith::STATUS_CANCELLED;
             }
             $results[$loopDate->dateString()][$addEvent->id] = $json ? $addEvent->toJson($allDay) : $addEvent;
         }
         $loopDate->mday++;
     }
 }
开发者ID:AsylumCorp,项目名称:horde,代码行数:34,代码来源:Kronolith.php

示例7: isTomorrow

 public function isTomorrow()
 {
     $date = new Horde_Date(array('month' => $this->month, 'mday' => $this->mday - 1, 'year' => $this->year));
     return $date->compareDate(new Horde_Date(mktime(0, 0, 0))) == 0;
 }
开发者ID:horde,项目名称:horde,代码行数:5,代码来源:Day.php

示例8: getMessageChanges

 /**
  * Return message changes from the specified mailbox.
  *
  * @param Horde_ActiveSync_Folder_Imap $folder  The folder object.
  * @param array $options                        Additional options:
  *  - sincedate: (integer)  Timestamp of earliest message to retrieve.
  *               DEFAULT: 0 (Don't filter).
  *  - protocolversion: (float)  EAS protocol version to support.
  *                     DEFAULT: none REQUIRED
  *  - softdelete: (boolean)  If true, calculate SOFTDELETE data.
  *                           @since 2.8.0
  *
  * @return Horde_ActiveSync_Folder_Imap  The folder object, containing any
  *                                       change instructions for the device.
  *
  * @throws Horde_ActiveSync_Exception_FolderGone,
  *         Horde_ActiveSync_Exception, Horde_ActiveSync_Exception_StaleState
  */
 public function getMessageChanges(Horde_ActiveSync_Folder_Imap $folder, array $options = array())
 {
     $imap = $this->_getImapOb();
     $mbox = new Horde_Imap_Client_Mailbox($folder->serverid());
     // Note: non-CONDSTORE servers will return a highestmodseq of 0
     $status_flags = Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_UIDVALIDITY | Horde_Imap_Client::STATUS_UIDNEXT_FORCE | Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_FORCE_REFRESH;
     try {
         $status = $imap->status($mbox, $status_flags);
     } catch (Horde_Imap_Client_Exception $e) {
         // If we can't status the mailbox, assume it's gone.
         throw new Horde_ActiveSync_Exception_FolderGone($e);
     }
     $this->_logger->info(sprintf('[%s] IMAP status: %s', $this->_procid, serialize($status)));
     $flags = array();
     $categories = array();
     $modseq = $status[Horde_ActiveSync_Folder_Imap::HIGHESTMODSEQ];
     if ($modseq && $folder->modseq() > 0 && $folder->modseq() < $modseq) {
         $this->_logger->info(sprintf('[%s] CONDSTORE and CHANGES', $this->_procid));
         $folder->checkValidity($status);
         $query = new Horde_Imap_Client_Fetch_Query();
         $query->modseq();
         $query->flags();
         $query->headerText(array('peek' => true));
         try {
             $fetch_ret = $imap->fetch($mbox, $query, array('changedsince' => $folder->modseq()));
         } catch (Horde_Imap_Client_Exception $e) {
             $this->_logger->err($e->getMessage());
             throw new Horde_ActiveSync_Exception($e);
         }
         // Prepare the changes and flags array, ensuring no changes after
         // $modseq sneak in yet (they will be caught on the next PING or
         // SYNC).
         $changes = array();
         // Get custom flags to use as categories.
         $msgFlags = $this->_getMsgFlags();
         foreach ($fetch_ret as $uid => $data) {
             if ($options['sincedate']) {
                 $since = new Horde_Date($options['sincedate']);
                 $headers = Horde_Mime_Headers::parseHeaders($data->getHeaderText());
                 try {
                     $date = new Horde_Date($headers->getValue('Date'));
                     if ($date->compareDate($since) <= -1) {
                         // Ignore, it's out of the FILTERTYPE range.
                         $this->_logger->info(sprintf('[%s] Ignoring UID %s since it is outside of the FILTERTYPE (%s)', $this->_procid, $uid, $headers->getValue('Date')));
                         continue;
                     }
                 } catch (Horde_Date_Exception $e) {
                 }
             }
             if ($data->getModSeq() <= $modseq) {
                 $changes[] = $uid;
                 $flags[$uid] = array('read' => array_search(Horde_Imap_Client::FLAG_SEEN, $data->getFlags()) !== false ? 1 : 0);
                 if ($options['protocolversion'] > Horde_ActiveSync::VERSION_TWOFIVE) {
                     $flags[$uid]['flagged'] = array_search(Horde_Imap_Client::FLAG_FLAGGED, $data->getFlags()) !== false ? 1 : 0;
                 }
                 if ($options['protocolversion'] > Horde_ActiveSync::VERSION_TWELVEONE) {
                     $categories[$uid] = array();
                     foreach ($data->getFlags() as $flag) {
                         if (($key = array_search(strtolower($flag), array_map('strtolower', $msgFlags))) !== false) {
                             $categories[$uid][] = $msgFlags[$key];
                         }
                     }
                 }
             }
         }
         $folder->setChanges($changes, $flags, $categories);
         try {
             $deleted = $imap->vanished($mbox, $folder->modseq(), array('ids' => new Horde_Imap_Client_Ids($folder->messages())));
         } catch (Horde_Imap_Client_Excetion $e) {
             $this->_logger->err($e->getMessage());
             throw new Horde_ActiveSync_Exception($e);
         }
         $folder->setRemoved($deleted->ids);
         if (!empty($options['softdelete']) && !empty($options['sincedate'])) {
             $this->_logger->info(sprintf('[%s] Polling for SOFTDELETE in %s before %d', $this->_procid, $folder->serverid(), $options['sincedate']));
             $query = new Horde_Imap_Client_Search_Query();
             $query->dateSearch(new Horde_Date($options['sincedate']), Horde_Imap_Client_Search_Query::DATE_BEFORE);
             $query->ids(new Horde_Imap_Client_Ids($folder->messages()));
             try {
                 $search_ret = $imap->search($mbox, $query, array('results' => array(Horde_Imap_Client::SEARCH_RESULTS_MATCH)));
             } catch (Horde_Imap_Client_Exception $e) {
                 $this->_logger->err($e->getMessage());
//.........这里部分代码省略.........
开发者ID:jubinpatel,项目名称:horde,代码行数:101,代码来源:Adapter.php

示例9: addCoverDates

 /**
  * Adds an event to all the days it covers.
  *
  * @param array $result              The current result list.
  * @param Kronolith_Event $event     An event object.
  * @param Horde_Date $eventStart     The event's start of the actual
  *                                   recurrence.
  * @param Horde_Date $eventEnd       The event's end of the actual
  *                                   recurrence.
  * @param boolean $json              Store the results of the events'
  *                                   toJson() method?
  * @param Horde_Date $originalStart  The actual starting time of a single
  *                                   event spanning multiple days.
  * @param Horde_Date $originalEnd    The actual ending time of a single
  *                                   event spanning multiple days.
  */
 public static function addCoverDates(&$results, $event, $eventStart, $eventEnd, $json, $originalStart = null, $originalEnd = null, Horde_Date $endDate = null)
 {
     $loopDate = new Horde_Date(array('month' => $eventStart->month, 'mday' => $eventStart->mday, 'year' => $eventStart->year));
     $allDay = $event->isAllDay();
     while ($loopDate->compareDateTime($eventEnd) <= 0 && $loopDate->compareDateTime($endDate) <= 0) {
         if (!$allDay || $loopDate->compareDateTime($eventEnd) != 0) {
             $addEvent = clone $event;
             if ($originalStart) {
                 $addEvent->originalStart = $originalStart;
             }
             if ($originalEnd) {
                 $addEvent->originalEnd = $originalEnd;
             }
             /* If this is the start day, set the start time to
              * the real start time, otherwise set it to
              * 00:00 */
             if ($loopDate->compareDate($eventStart) != 0) {
                 $addEvent->start = clone $loopDate;
                 $addEvent->start->hour = $addEvent->start->min = $addEvent->start->sec = 0;
                 $addEvent->first = false;
             } else {
                 $addEvent->start = $eventStart;
             }
             /* If this is the end day, set the end time to the
              * real event end, otherwise set it to 23:59. */
             if ($loopDate->compareDate($eventEnd) != 0) {
                 $addEvent->end = clone $loopDate;
                 $addEvent->end->hour = 23;
                 $addEvent->end->min = $addEvent->end->sec = 59;
                 $addEvent->last = false;
             } else {
                 $addEvent->end = $eventEnd;
             }
             if ($addEvent->recurs() && $addEvent->recurrence->hasCompletion($loopDate->year, $loopDate->month, $loopDate->mday)) {
                 $addEvent->status = Kronolith::STATUS_CANCELLED;
             }
             $results[$loopDate->dateString()][$addEvent->id] = $json ? $addEvent->toJson(array('all_day' => $allDay)) : $addEvent;
         }
         $loopDate->mday++;
     }
 }
开发者ID:horde,项目名称:horde,代码行数:57,代码来源:Kronolith.php


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