Checks if ranges are equal.

@param   DateTimeRange  $range  The range to compare to.

@return  boolean

@since   2.0.0
490375
public function equals(DateTimeRange $range)
	{
		return $this->start->equals($range->start) && $this->end->equals($range->end) && $this->interval->equals($range->interval);
	}
178442
public function overlap(DatePeriodDateTime $comparison) : bool
    {
        $start = $this;
        $end = $this->getEndDate();

        $comparisonStart = $comparison;
        $comparisonEnd = $comparison->getEndDate();

        /*
         *            L     H
         * C :        |_____|
         * 1 :      __|__   |
         * 2 :     ___|     |
         * 3 :        |   __|___
         * 4 :        |     |___
         * 5 :      __|_____|__
         * 6 :        |_____|___
         * 7 :      __|_____|
         * 8 :        |_____|
         * 9 :   __   |     |
         * 10:        |     | __
         * 11:        |  __ |
         */

        // case 1
        if ($start->lt($comparisonStart) && $comparisonStart->gt($start) && $end->lt($comparisonEnd) && $end->gt($comparisonStart)) {
            return true;
        }

        // case 2
        if ($end->eq($comparisonStart)) {
            return false;
        }

        // case 3
        if ($start->gt($comparisonStart) && $start->lt($comparisonEnd) && $end->gt($comparisonEnd)) {
            return true;
        }

        // case 4
        if ($start->eq($comparisonEnd)) {
            return false;
        }

        // case 5
        if ($start->lt($comparisonStart) && $end->gt($comparisonEnd)) {
            return true;
        }

        // case 6
        if ($start->eq($comparisonStart) && $end->gt($comparisonEnd)) {
            return true;
        }

        // case 7
        if ($start->lt($comparisonStart) && $end->eq($comparisonEnd)) {
            return true;
        }

        // case 8
        if ($start->eq($comparisonStart) && $end->eq($comparisonEnd)) {
            return true;
        }

        // case 11
        if ($start->gt($comparisonStart) && $end->lt($comparisonEnd)) {
            return true;
        }

        return false;
    }
472918
public static function equals(TimeSlot $a, TimeSlot $b) {

        // Compare the start dates.
        if (false === DateTimeHelper::equals($a->getStartDate(), $b->getStartDate())) {
            return false;
        }

        // Compare the end dates.
        if (false === DateTimeHelper::equals($a->getEndDate(), $b->getEndDate())) {
            return false;
        }

        // Compare the time slots count.
        if (count($a->getTimeSlots()) !== count($b->getTimeSlots())) {
            return false;
        }

        // Handle each time slot.
        for ($i = count($a->getTimeSlots()) - 1; 0 <= $i; --$i) {
            if (false === static::equals($a->getTimeSlots()[$i], $b->getTimeSlots()[$i])) {
                return false;
            }
        }

        //
        return true;
    }
715946
private static function cast(DateTimeRange $range)
	{
		$start = new Date($range->start());
		$end   = new Date($range->end());

		return new DateRange($start, $end);
	}
539326
public function clearCellsContents($range)
    {
        if ($range == '')
            throw new Exception('Range not specified');
        
        //Build URI
        $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . 
                  '/cells/clearcontents?range=' . $range;
        //Sign URI
        $signedURI = Utils::sign($strURI);
        
        //Send request and receive response
        $response = Utils::processCommand($signedURI, 'POST', '', '');
        $json = json_decode($response);
        if ($json->Code == 200)
            return true;
        else
            return false;
    }
1191049
public function includesRange(DateTimeRange $range)
	{
		return $this->includes($range->start) && $this->includes($range->end);
	}
612636
private function splitRanges(string $ranges): void
    {
        $matches = [];
        if (!preg_match('#^[\-|\+]{1}([0-9]+),([0-9]+) [\-\+]{1}([0-9]+),([0-9]+)$#', $ranges, $matches)) {
            throw new \RuntimeException('invalid ranges: ' . $ranges);
        }
        $this->pre  = ['from' => (int)$matches[1], 'to' => (int)$matches[2]];
        $this->post = ['from' => (int)$matches[3], 'to' => (int)$matches[4]];
    }
892976
public function overlapsExclusive(TimeRange $otherRange) : bool
    {
        return $this->containsExclusive($otherRange->start) || $this->containsExclusive($otherRange->end)
        || $this->encompasses($otherRange)
        || $otherRange->encompasses($this);
    }
403450
public function removeRange($from, $to)
    {
        foreach ($this->ranges as $key => $range) {
            if (array_diff_assoc(array_filter(['from' => $from, 'to' => $to]), $range) === []) {
                unset($this->ranges[$key]);

                return true;
            }
        }

        return false;
    }
215765
public function Deny ($range)
	{
		
		$formatted	= $this->formatRange ($range);
		
		if (!$formatted)
		{
			return FALSE;
		}
		
		$this->denyIPs[$formatted[0]]	= $formatted[1];
		return TRUE;
		
	}
541664
public function isWithinDayRange($rangeStart, $rangeEnd) {

    // Normalize our event's dates for comparison with the all-day range.
    $eventStart = stripTime($this->start);

    if (isset($this->end)) {
      $eventEnd = stripTime($this->end); // normalize
    }
    else {
      $eventEnd = $eventStart; // consider this a zero-duration event
    }

    // Check if the two whole-day ranges intersect.
    return $eventStart < $rangeEnd && $eventEnd >= $rangeStart;
  }
130158
public static function combination(array $ranges)
	{
		if (!self::isContiguous($ranges))
		{
			throw new \InvalidArgumentException('Unable to combine date ranges');
		}

		return new DateTimeRange($ranges[0]->start, $ranges[count($ranges) - 1]->end, $ranges[0]->interval);
	}
1122647
public static function range($range): ISeq
    {
        [$start, $end, $step] = Range::parse($range);

        if ($end === self::INFINITE) {
            $seq = new static(
                function () use ($start, $step) {
                    for ($i = $start; true; $i += $step) {
                        yield $i;
                    }
                }
            );

            return $seq->setIsInfinite();
        }

        return new static(range($start, $end, $step));
    }
904682
public static function combination(array $ranges)
	{
		$dateTimeRanges = array();

		foreach ($ranges as $range)
		{
			$dateTimeRanges[] = $range->range;
		}

		return self::cast(DateTimeRange::combination($dateTimeRanges));
	}
606249
public function removeDenied ($range)
	{
		
		$formatted	= $this->formatRange ($range);
		
		if (!$formatted)
		{
			return FALSE;
		}
		
		unset ($this->denyIPs[$formatted[0]]);
		return TRUE;
		
	}
382677
public function filterRange($range)
    {
        if (is_int($range)) {
            $level = $range;
            $depth = 0;
        } else {
            reset($range);
            $level = key($range);
            $depth = current($range);
        }

        if (1 === $level) {
            $nodeList = $this->xp->query('/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= '.$level.'  ]')->item(0);
        } else {
            $nodeList = $this->xp->query('/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= '.$level.' and ( descendant-or-self::*[ contains(@class, "open") or contains(@class, "active") ] or ancestor-or-self::*[ contains(@class, "open")  or contains(@class, "active") ] ) ]')->item(0);
        }

        if (!$nodeList) {
            return false;
        }

        if (false === $depth) {
            return $nodeList;
        }

        $depthNodelist = $this->xp->query('./descendant::*[ name() = "ul" and count( ancestor-or-self::ul ) > '.($level + $depth).' ]', $nodeList);

        foreach ($depthNodelist as $node) {
            $node->parentNode->removeChild($node);
        }

        if ($nodeList) {
            return $nodeList;
        } else {
            return false;
        }
    }
422346
public function contains( DateTime $datetime )
    {

        $lower = $this->lower->toUnixTimestamp();
        $upper = $this->upper->toUnixTimestamp();
        $working = $datetime->toUnixTimestamp();

        $lowerCompare = bccomp( $lower, $working );
        $upperCompare = bccomp( $upper, $working );

//        echo "\n{$lower} {$upper} {$working} {$lowerCompare} {$upperCompare}";

        // fucking hell, this was much more annoying than it should be
        if( $lowerCompare === 1 || ( $this->bounds & self::LOWER_CONTAIN_NOT and $lowerCompare === 0 ) ) {
            return false;
        }

        if( $upperCompare === -1 || ( $this->bounds & self::UPPER_CONTAIN_NOT and $upperCompare === 0 ) ) {
            return false;
        }

        return true;

    }