Example #1
0
 /**
  * Returns a gap range between two ranges.
  *
  * @param   DateTimeRange  $range  The range to compare to.
  *
  * @return  DateTimeRange
  *
  * @since   2.0.0
  */
 public function gap(DateTimeRange $range)
 {
     if ($this->overlaps($range)) {
         return self::emptyRange();
     }
     if ($this->start->isBefore($range->start)) {
         $lower = $this;
         $higher = $range;
     } else {
         $lower = $range;
         $higher = $this;
     }
     return new DateTimeRange($lower->end->add($this->interval), $higher->start->sub($this->interval), $this->interval);
 }
Example #2
0
 /**
  * Checks if the current date is before the date given as parameter.
  *
  * @param   Date  $date  The date to compare to.
  *
  * @return  boolean
  *
  * @since   2.0.0
  */
 public function isBefore(Date $date)
 {
     return $this->datetime->isBefore($date->datetime);
 }