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


PHP Horde_Date::compareDateTime方法代码示例

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


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

示例1: getBusyTimes

 /**
  * Retrieve the busy times from this event within the given timeframe.  This
  * is trivial for non-recurring events but recurring events need to be
  * expanded.
  *
  * @param Horde_Date $startDate The start point.
  * @param Horde_Date $endDate   The end point.
  *
  * @return array The list of busy times (only the start times of the event).
  */
 public function getBusyTimes(Horde_Date $startDate, Horde_Date $endDate)
 {
     if (!$this->recurs()) {
         if ($startDate->compareDateTime($this->_start) > 0 || $endDate->compareDateTime($this->_start) < 0) {
             return array();
         }
         return array($this->_start->timestamp());
     } else {
         $result = array();
         $next = $this->_recurrence->nextRecurrence($startDate);
         while ($next) {
             if ($endDate->compareDateTime($next) < 0) {
                 break;
             }
             if (!$this->_recurrence->hasException($next->year, $next->month, $next->mday)) {
                 $result[] = $next->timestamp();
             }
             $next->mday++;
             $next = $this->_recurrence->nextRecurrence($next);
         }
         return $result;
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:33,代码来源:Event.php

示例2: includes

 /**
  * Is a Horde_Date within this span?
  *
  * @param Horde_Date $date
  */
 public function includes($date)
 {
     return $this->begin->compareDateTime($date) <= 0 && $this->end->compareDateTime($date) >= 0;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:9,代码来源:Span.php

示例3: readForm


//.........这里部分代码省略.........
         }
         $this->start = new Horde_Date(array('hour' => $start_hour, 'min' => $start_min, 'month' => $start_month, 'mday' => $start_day, 'year' => $start_year), $this->timezone);
     }
     // Event end.
     if ($end_date = Horde_Util::getFormData('end_date')) {
         // From ajax interface.
         $this->end = Kronolith::parseDate($end_date . ' ' . Horde_Util::getFormData('end_time'), true, $this->timezone);
         if ($allDay) {
             $this->end->hour = $this->end->min = $this->end->sec = 0;
             $this->end->mday++;
         }
     } elseif (Horde_Util::getFormData('end_or_dur') == 1) {
         // Event duration from traditional interface.
         $this->end = new Horde_Date(array('hour' => $start_hour + $dur_hour, 'min' => $start_min + $dur_min, 'month' => $start_month, 'mday' => $start_day + $dur_day, 'year' => $start_year));
     } else {
         // From traditional interface.
         $end = Horde_Util::getFormData('end');
         $end_year = $end['year'];
         $end_month = $end['month'];
         $end_day = $end['day'];
         $end_hour = Horde_Util::getFormData('end_hour');
         $end_min = Horde_Util::getFormData('end_min');
         $end_am_pm = Horde_Util::getFormData('end_am_pm');
         if (!$prefs->getValue('twentyFour')) {
             if ($end_am_pm == 'PM') {
                 if ($end_hour != 12) {
                     $end_hour += 12;
                 }
             } elseif ($end_hour == 12) {
                 $end_hour = 0;
             }
         }
         $this->end = new Horde_Date(array('hour' => $end_hour, 'min' => $end_min, 'month' => $end_month, 'mday' => $end_day, 'year' => $end_year), $this->timezone);
         if ($this->end->compareDateTime($this->start) < 0) {
             $this->end = new Horde_Date($this->start);
         }
     }
     $this->allday = false;
     // Alarm.
     if (!is_null($alarm = Horde_Util::getFormData('alarm'))) {
         if ($alarm) {
             $value = Horde_Util::getFormData('alarm_value');
             $unit = Horde_Util::getFormData('alarm_unit');
             if ($value == 0) {
                 $value = $unit = 1;
             }
             $this->alarm = $value * $unit;
             // Notification.
             if (Horde_Util::getFormData('alarm_change_method')) {
                 $types = Horde_Util::getFormData('event_alarms');
                 $methods = array();
                 if (!empty($types)) {
                     foreach ($types as $type) {
                         $methods[$type] = array();
                         switch ($type) {
                             case 'notify':
                                 $methods[$type]['sound'] = Horde_Util::getFormData('event_alarms_sound');
                                 break;
                             case 'mail':
                                 $methods[$type]['email'] = Horde_Util::getFormData('event_alarms_email');
                                 break;
                             case 'popup':
                                 break;
                         }
                     }
                 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:67,代码来源:Event.php

示例4: listAlarms

 /**
  * @throws Kronolith_Exception
  */
 public function listAlarms($date, $fullevent = false)
 {
     $allevents = $this->listEvents($date, null, array('has_alarm' => true));
     $events = array();
     foreach (array_keys($allevents) as $eventId) {
         $event = $this->getEvent($eventId);
         if (!$event->recurs()) {
             $start = new Horde_Date($event->start);
             $start->min -= $event->alarm;
             if ($start->compareDateTime($date) <= 0 && $date->compareDateTime($event->end) <= -1) {
                 $events[] = $fullevent ? $event : $eventId;
             }
         } else {
             if ($next = $event->recurrence->nextRecurrence($date)) {
                 if ($event->recurrence->hasException($next->year, $next->month, $next->mday)) {
                     continue;
                 }
                 $start = new Horde_Date($next);
                 $start->min -= $event->alarm;
                 $end = new Horde_Date(array('year' => $next->year, 'month' => $next->month, 'mday' => $next->mday, 'hour' => $event->end->hour, 'min' => $event->end->min, 'sec' => $event->end->sec));
                 if ($start->compareDateTime($date) <= 0 && $date->compareDateTime($end) <= -1) {
                     if ($fullevent) {
                         $event->start = $start;
                         $event->end = $end;
                         $events[] = $event;
                     } else {
                         $events[] = $eventId;
                     }
                 }
             }
         }
     }
     return is_array($events) ? $events : array();
 }
开发者ID:Gomez,项目名称:horde,代码行数:37,代码来源:Kolab.php

示例5: listAlarms

 /**
  *
  * @param Horde_Date $date    The date to list alarms for
  * @param boolean $fullevent  Return the full event objects?
  *
  * @return array  An array of event ids, or Kronolith_Event objects
  * @throws Kronolith_Exception
  */
 public function listAlarms($date, $fullevent = false)
 {
     $allevents = $this->listEvents($date, null, array('has_alarm' => true));
     $events = array();
     foreach ($allevents as $dayevents) {
         foreach ($dayevents as $event) {
             if (!$event->recurs()) {
                 $start = new Horde_Date($event->start);
                 $start->min -= $event->alarm;
                 if ($start->compareDateTime($date) <= 0 && $date->compareDateTime($event->end) <= -1) {
                     $events[] = $fullevent ? $event : $event->id;
                 }
             } else {
                 // Need to start at the beginning of the day to catch the
                 // case where we might be within the event's timespan
                 // when we call this, hence nextRecurrence() would miss the
                 // current event.
                 $start = clone $date;
                 $start->min = 0;
                 $start->hour = 0;
                 $start->sec = 0;
                 if ($next = $event->recurrence->nextRecurrence($start)) {
                     if ($event->recurrence->hasException($next->year, $next->month, $next->mday)) {
                         continue;
                     }
                     $start = new Horde_Date($next);
                     $start->min -= $event->alarm;
                     $diff = $event->start->diff($event->end);
                     $end = new Horde_Date(array('year' => $next->year, 'month' => $next->month, 'mday' => $next->mday + $diff, 'hour' => $event->end->hour, 'min' => $event->end->min, 'sec' => $event->end->sec));
                     if ($start->compareDateTime($date) <= 0 && $date->compareDateTime($end) <= -1) {
                         if ($fullevent) {
                             $event->start = $next;
                             $event->end = $end;
                             $events[] = $event;
                         } else {
                             $events[] = $event->id;
                         }
                     }
                 }
             }
         }
     }
     return $events;
 }
开发者ID:horde,项目名称:horde,代码行数:52,代码来源:Sql.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: readForm


//.........这里部分代码省略.........
         if (Horde_Util::getFormData('end_or_dur') == 1) {
             if ($allDay) {
                 $start_hour = 0;
                 $start_min = 0;
                 $dur_day = 0;
                 $dur_hour = 24;
                 $dur_min = 0;
             } else {
                 $dur_day = (int) Horde_Util::getFormData('dur_day');
                 $dur_hour = (int) Horde_Util::getFormData('dur_hour');
                 $dur_min = (int) Horde_Util::getFormData('dur_min');
             }
         }
         $this->start = new Horde_Date(array('hour' => $start_hour, 'min' => $start_min, 'month' => $start_month, 'mday' => $start_day, 'year' => $start_year), $this->timezone);
     }
     // Event end.
     if ($end_date = Horde_Util::getFormData('end_date')) {
         // From ajax interface.
         $this->end = Kronolith::parseDate($end_date . ' ' . Horde_Util::getFormData('end_time'), true, $this->timezone);
         if ($allDay) {
             $this->end->hour = $this->end->min = $this->end->sec = 0;
             $this->end->mday++;
         }
     } elseif (Horde_Util::getFormData('end_or_dur') == 1) {
         // Event duration from traditional interface.
         $this->end = new Horde_Date(array('hour' => $start_hour + $dur_hour, 'min' => $start_min + $dur_min, 'month' => $start_month, 'mday' => $start_day + $dur_day, 'year' => $start_year));
     } else {
         // From traditional interface.
         $end = Horde_Util::getFormData('end');
         $end_year = $end['year'];
         $end_month = $end['month'];
         $end_day = $end['day'];
         $end_hour = Horde_Util::getFormData('end_hour');
         $end_min = Horde_Util::getFormData('end_min');
         $end_am_pm = Horde_Util::getFormData('end_am_pm');
         if (!$prefs->getValue('twentyFour')) {
             if ($end_am_pm == 'PM') {
                 if ($end_hour != 12) {
                     $end_hour += 12;
                 }
             } elseif ($end_hour == 12) {
                 $end_hour = 0;
             }
         }
         $this->end = new Horde_Date(array('hour' => $end_hour, 'min' => $end_min, 'month' => $end_month, 'mday' => $end_day, 'year' => $end_year), $this->timezone);
         if ($this->end->compareDateTime($this->start) < 0) {
             $this->end = new Horde_Date($this->start);
         }
     }
     $this->allday = false;
     // Alarm.
     if (!is_null($alarm = Horde_Util::getFormData('alarm'))) {
         if ($alarm) {
             $value = Horde_Util::getFormData('alarm_value');
             $unit = Horde_Util::getFormData('alarm_unit');
             if ($value == 0) {
                 $value = $unit = 1;
             }
             $this->alarm = $value * $unit;
             // Notification.
             if (Horde_Util::getFormData('alarm_change_method')) {
                 $types = Horde_Util::getFormData('event_alarms');
                 $methods = array();
                 if (!empty($types)) {
                     foreach ($types as $type) {
                         $methods[$type] = array();
                         switch ($type) {
                             case 'notify':
                                 $methods[$type]['sound'] = Horde_Util::getFormData('event_alarms_sound');
                                 break;
                             case 'mail':
                                 $methods[$type]['email'] = Horde_Util::getFormData('event_alarms_email');
                                 break;
                             case 'popup':
                                 break;
                         }
                     }
                 }
                 $this->methods = $methods;
             } else {
                 $this->methods = array();
             }
         } else {
             $this->alarm = 0;
             $this->methods = array();
         }
     }
     // Recurrence.
     $this->recurrence = $this->readRecurrenceForm($this->start, $this->timezone, $this->recurrence);
     // Convert to local timezone.
     $this->setTimezone(false);
     $this->_handleResources($existing);
     // Tags.
     $this->tags = Horde_Util::getFormData('tags', $this->tags);
     // Geolocation
     if (Horde_Util::getFormData('lat') && Horde_Util::getFormData('lon')) {
         $this->geoLocation = array('lat' => Horde_Util::getFormData('lat'), 'lon' => Horde_Util::getFormData('lon'), 'zoom' => Horde_Util::getFormData('zoom'));
     }
     $this->initialized = true;
 }
开发者ID:GenerationLabs,项目名称:horde,代码行数:101,代码来源:Event.php

示例8: nextRecurrence

 /**
  * Finds the next recurrence of this event that's after $afterDate.
  *
  * @param Horde_Date|string $after  Return events after this date.
  *
  * @return Horde_Date|boolean  The date of the next recurrence or false
  *                             if the event does not recur after
  *                             $afterDate.
  */
 public function nextRecurrence($after)
 {
     if (!$after instanceof Horde_Date) {
         $after = new Horde_Date($after);
     } else {
         $after = clone $after;
     }
     // Make sure $after and $this->start are in the same TZ
     $after->setTimezone($this->start->timezone);
     if ($this->start->compareDateTime($after) >= 0) {
         return clone $this->start;
     }
     if ($this->recurInterval == 0 && empty($this->rdates)) {
         return false;
     }
     switch ($this->getRecurType()) {
         case self::RECUR_DAILY:
             $diff = $this->start->diff($after);
             $recur = ceil($diff / $this->recurInterval);
             if ($this->recurCount && $recur >= $this->recurCount) {
                 return false;
             }
             $recur *= $this->recurInterval;
             $next = $this->start->add(array('day' => $recur));
             if ((!$this->hasRecurEnd() || $next->compareDateTime($this->recurEnd) <= 0) && $next->compareDateTime($after) >= 0) {
                 return $next;
             }
             break;
         case self::RECUR_WEEKLY:
             if (empty($this->recurData)) {
                 return false;
             }
             $start_week = Horde_Date_Utils::firstDayOfWeek($this->start->format('W'), $this->start->year);
             $start_week->timezone = $this->start->timezone;
             $start_week->hour = $this->start->hour;
             $start_week->min = $this->start->min;
             $start_week->sec = $this->start->sec;
             // Make sure we are not at the ISO-8601 first week of year while
             // still in month 12...OR in the ISO-8601 last week of year while
             // in month 1 and adjust the year accordingly.
             $week = $after->format('W');
             if ($week == 1 && $after->month == 12) {
                 $theYear = $after->year + 1;
             } elseif ($week >= 52 && $after->month == 1) {
                 $theYear = $after->year - 1;
             } else {
                 $theYear = $after->year;
             }
             $after_week = Horde_Date_Utils::firstDayOfWeek($week, $theYear);
             $after_week->timezone = $this->start->timezone;
             $after_week_end = clone $after_week;
             $after_week_end->mday += 7;
             $diff = $start_week->diff($after_week);
             $interval = $this->recurInterval * 7;
             $repeats = floor($diff / $interval);
             if ($diff % $interval < 7) {
                 $recur = $diff;
             } else {
                 /**
                  * If the after_week is not in the first week interval the
                  * search needs to skip ahead a complete interval. The way it is
                  * calculated here means that an event that occurs every second
                  * week on Monday and Wednesday with the event actually starting
                  * on Tuesday or Wednesday will only have one incidence in the
                  * first week.
                  */
                 $recur = $interval * ($repeats + 1);
             }
             if ($this->hasRecurCount()) {
                 $recurrences = 0;
                 /**
                  * Correct the number of recurrences by the number of events
                  * that lay between the start of the start week and the
                  * recurrence start.
                  */
                 $next = clone $start_week;
                 while ($next->compareDateTime($this->start) < 0) {
                     if ($this->recurOnDay((int) pow(2, $next->dayOfWeek()))) {
                         $recurrences--;
                     }
                     ++$next->mday;
                 }
                 if ($repeats > 0) {
                     $weekdays = $this->recurData;
                     $total_recurrences_per_week = 0;
                     while ($weekdays > 0) {
                         if ($weekdays % 2) {
                             $total_recurrences_per_week++;
                         }
                         $weekdays = ($weekdays - $weekdays % 2) / 2;
                     }
//.........这里部分代码省略.........
开发者ID:claudineyqr,项目名称:Kolab-Roundcube-Calendar,代码行数:101,代码来源:Horde_Date_Recurrence.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

示例10: _parse


//.........这里部分代码省略.........
                     case 'windshear':
                         // Parse windshear, if available
                         if ($result[4] == 'KTS') {
                             $result[4] = 'KT';
                         }
                         $pointer['windshear'] = round(Horde_Service_Weather::convertSpeed($result[3], $result[4], $this->_unitMap[self::UNIT_KEY_SPEED]));
                         $pointer['windshearHeight'] = $result[1] * 100;
                         $pointer['windshearDegrees'] = $result[2];
                         $pointer['windshearDirection'] = Horde_Service_Weather::degToDirection($result[2]);
                         break;
                     case 'tempmax':
                         $forecastData['temperatureHigh'] = Horde_Service_Weather::convertTemperature($result[1], 'c', $this->_unitMap[self::UNIT_KEY_TEMP]);
                         break;
                     case 'tempmin':
                         // Parse max/min temperature
                         $forecastData['temperatureLow'] = Horde_Service_Weather::convertTemperature($result[1], 'c', $this->_unitMap[self::UNIT_KEY_TEMP]);
                         break;
                     case 'tempmaxmin':
                         $forecastData['temperatureHigh'] = Horde_Service_Weather::convertTemperature($result[1], 'c', $this->_unitMap[self::UNIT_KEY_TEMP]);
                         $forecastData['temperatureLow'] = Horde_Service_Weather::convertTemperature($result[4], 'c', $this->_unitMap[self::UNIT_KEY_TEMP]);
                         break;
                     case 'from':
                         // Next timeperiod is coming up, prepare array and
                         // set pointer accordingly
                         $fromTime = clone $start_time;
                         if (sizeof($result) > 2) {
                             // The ICAO way
                             $fromTime->hour = $result[2];
                             $fromTime->min = $result[3];
                         } else {
                             // The Australian way (Hey mates!)
                             $fromTime->hour = $result[1];
                         }
                         if ($start_time->compareDateTime($fromTime) >= 1) {
                             $fromTime->mday++;
                         }
                         $fromTime = (string) $fromTime;
                         $forecastData['time'][$fromTime] = array();
                         $fmcCount = 0;
                         $pointer =& $forecastData['time'][$fromTime];
                         break;
                     case 'fmc':
                         // Test, if this is a probability for the next FMC
                         if (isset($result[2]) && preg_match('/^BECMG|TEMPO$/i', $taf[$i + 1], $lresult)) {
                             // Set type to BECMG or TEMPO
                             $type = $lresult[0];
                             // Set probability
                             $probability = $result[2];
                             // Now extract time for this group
                             if (preg_match('/^(\\d{2})(\\d{2})$/i', $taf[$i + 2], $lresult)) {
                                 $from = clone $start_time;
                                 $from->hour = $lresult[1];
                                 if ($start_time->compareDateTime($from) >= 1) {
                                     $from->mday++;
                                 }
                                 $to = clone $from;
                                 $to->hour = $lresult[2];
                                 if ($start_time->compareDateTime($to) >= 1) {
                                     $to->mday++;
                                 }
                                 // As we now have type, probability and time for this FMC
                                 // from our TAF, increase field-counter
                                 $i += 2;
                             } else {
                                 // No timegroup present, so just increase field-counter by one
                                 $i += 1;
开发者ID:horde,项目名称:horde,代码行数:67,代码来源:Taf.php


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