Horde_Date::compareDateTime PHP Method

compareDateTime() public method

Compares this to another date object, including times, to see which one is greater (later). Assumes that the dates are in the same timezone.
public compareDateTime ( mixed $other ) : integer
$other mixed The date to compare to.
return integer == 0 if they are equal >= 1 if $this is greater (later) <= -1 if $other is greater (later)
    public function compareDateTime($other)
    {
        if (!$other instanceof Horde_Date) {
            $other = new Horde_Date($other);
        }
        if ($diff = $this->compareDate($other)) {
            return $diff;
        }
        return $this->compareTime($other);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * 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;
     }
 }
All Usage Examples Of Horde_Date::compareDateTime