Returns a diff of the supplied date time.

@param DateTimeBase $other
@param bool         $absolute

@return \DateInterval
11119
public function diff(DateTimeBase $other, bool $absolute = false)
    {
        return $this->dateTime->diff($other->dateTime, $absolute);
    }
193023
public function diffInWeeks($date = null, $absolute = true)
    {
        return (int) ($this->diffInDays($date, $absolute) / static::DAYS_PER_WEEK);
    }
793294
public function floatDiffInRealSeconds($date = null, $absolute = true)
    {
        return $this->diffInRealMicroseconds($date, $absolute) / static::MICROSECONDS_PER_SECOND;
    }
1280199
public static function instance(DateInterval $di)
    {
        if (self::wasCreatedFromDiff($di)) {
            throw new InvalidArgumentException('Can not instance a Interval object created from DateTime::diff().');
        }

        $instance = new static($di->y, $di->m, 0, $di->d, $di->h, $di->i, $di->s);
        $instance->invert = $di->invert;
        $instance->days = $di->days;

        return $instance;
    }
393142
public function isFollowedByAtMidnight(DateTimeInterval $other): bool
	{
		$left = clone $other->getLeft()->getValue();

		return (
			Utils::isSameDate($this->getRight()->getValue(), $left->modify('-1 day'))
			&& $this->getRight()->getValue()->format('H:i:s') === '23:59:59'
			&& $other->getLeft()->getValue()->format('H:i:s') === '00:00:00'
		);
	}
1353917
public function compare($a, $b): int
    {
        $aDate = new \DateTime($a['date']);
        $bDate = new \DateTime($b['date']);

        return $aDate <=> $bDate;
    }
800473
public function diffInRealMicroseconds($date = null, $absolute = true)
    {
        /** @var CarbonInterface $date */
        $date = $this->resolveCarbon($date);
        $value = ($date->timestamp - $this->timestamp) * static::MICROSECONDS_PER_SECOND +
            $date->micro - $this->micro;

        return $absolute ? abs($value) : $value;
    }
631954
public static function diff($date1, $date2, $type = 'days', $round = true) {
		$result = strtotime($date2) - strtotime($date1);
		switch ($type) {
			case 'days':
				$result = $result / 86400;
				break;
			case 'abs days':
				$result = abs($result / 86400);
				break;
			case 'seconds':
				return $result;
				break;
			case 'abs seconds':
				return abs($result);
				break;
		}
		// rounding
		if ($round) {
			$result = (int) round($result);
		}
		return $result;
	}
1074663
public function diffFiltered(Interval $ci, Closure $callback, Date $dt = null, $abs = true)
    {
        $start = $this;
        $end = $dt ?: static::now($this->getTimezone());
        $inverse = false;

        if ($end < $start) {
            $start = $end;
            $end = $this;
            $inverse = true;
        }

        $period = new DatePeriod($start, $ci, $end);
        $vals = array_filter(
            iterator_to_array($period),
            function (DateTimeInterface $date) use ($callback) {
                return call_user_func($callback, Date::instance($date));
            }
        );

        $diff = count($vals);

        return $inverse && !$abs ? -$diff : $diff;
    }
1082415
public function floatDiffInRealHours($date = null, $absolute = true)
    {
        return $this->floatDiffInRealMinutes($date, $absolute) / static::MINUTES_PER_HOUR;
    }
860997
public function daysBetween(Date $other) : int
    {
        return $this->dateTime->diff($other->dateTime, true)->days;
    }
704980
public function diffInWeeks(Date $dt = null, $abs = true)
    {
        return (int) ($this->diffInDays($dt, $abs) / static::DAYS_PER_WEEK);
    }
1357301
public function diffInDaysFiltered(Closure $callback, Date $dt = null, $abs = true)
    {
        return $this->diffFiltered(Interval::day(), $callback, $dt, $abs);
    }
1047966
public function diffInWeekdays($date = null, $absolute = true)
    {
        return $this->diffInDaysFiltered(function (CarbonInterface $date) {
            return $date->isWeekday();
        }, $date, $absolute);
    }
265686
public function floatDiffInMonths($date = null, $absolute = true)
    {
        $start = $this;
        $end = $this->resolveCarbon($date);
        $ascending = ($start <= $end);
        $sign = $absolute || $ascending ? 1 : -1;
        if (!$ascending) {
            $_end = $start;
            $start = $end;
            $end = $_end;
            unset($_end);
        }
        $monthsDiff = $start->diffInMonths($end);
        /** @var Carbon|CarbonImmutable $floorEnd */
        $floorEnd = $start->copy()->addMonths($monthsDiff);

        if ($floorEnd >= $end) {
            return $sign * $monthsDiff;
        }

        /** @var Carbon|CarbonImmutable $startOfMonthAfterFloorEnd */
        $startOfMonthAfterFloorEnd = $floorEnd->copy()->addMonth()->startOfMonth();

        if ($startOfMonthAfterFloorEnd > $end) {
            return $sign * ($monthsDiff + $floorEnd->floatDiffInDays($end) / $floorEnd->daysInMonth);
        }

        return $sign * ($monthsDiff + $floorEnd->floatDiffInDays($startOfMonthAfterFloorEnd) / $floorEnd->daysInMonth + $startOfMonthAfterFloorEnd->floatDiffInDays($end) / $end->daysInMonth);
    }
409762
private function fullDiff() : DateInterval
    {
        if (null === $this->fullDiff) {
            $this->fullDiff = $this->from->diff($this->until);
        }
        
        return $this->fullDiff;
    }
99429
public function diffInHours(Time $dt = null, $abs = true)
        {
            return (int) ($this->diffInSeconds($dt, $abs) / self::SECONDS_PER_MINUTE / self::MINUTES_PER_HOUR);
        }