Get the difference in days using a filter closure

@param Closure $callback
@param Time  $dt
@param boolean $abs      Get the absolute of the difference

@return int
331569
public function diffInDaysFiltered(Closure $callback, Time $dt = null, $abs = true)
         {
              $start = $this;
              $end = ($dt === null) ? static::now($this->tz) : $dt;
              $inverse = false;

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

              $period = new DatePeriod($start, new DateInterval('P1D'), $end);
              $days = array_filter(iterator_to_array($period), function (DateTime $date) use ($callback) {
                    return call_user_func($callback, Time::instance($date));
              });

              $diff = count($days);

              return $inverse && !$abs ? -$diff : $diff;
         }
1082415
public function floatDiffInRealHours($date = null, $absolute = true)
    {
        return $this->floatDiffInRealMinutes($date, $absolute) / static::MINUTES_PER_HOUR;
    }
657628
public function difference($date = null) {
        if (!empty($date)) {
            $this->setDate($date, true);
        }
        $interval = (array) $this->dateTime->diff($this->dateTimeDiff);
        return $interval['days'];
    }
1019076
public function avg($callback = null)
    {
        $callback = $this->valueRetriever($callback);

        $items = $this->map(function ($value) use ($callback) {
            return $callback($value);
        })->filter(function ($value) {
            return ! is_null($value);
        });

        if ($count = $items->count()) {
            return $items->sum() / $count;
        }
    }
610805
public function diff($datetime, $absolute = false)
    {
        $d1 = clone $this;
        $d2 = $datetime instanceof \DateTime ? new static($datetime->format(DateTime::ISO8601)) : clone $datetime;

        $interval = new DateInterval('PT0.000000S');
        foreach (get_object_vars(parent::diff($datetime)) as $property => $value) {
            $interval->{$property} = $value;
        }
        $interval->s = 0;

        $negative = $d1->getTimestampWithMicroseconds() > $d2->getTimestampWithMicroseconds();
        $diff = abs($d1->getTimestampWithMicroseconds() - $d2->getTimestampWithMicroseconds());

        $seconds = intval($diff);
        $microseconds = round($diff - $seconds, 6) * 1e6;

        $now = new \DateTime('now');
        $start = $now->getTimestamp();

        $operation = $negative ? 'sub' : 'add';
        $now->$operation($interval);

        $end = $now->getTimestamp();
        $antiseconds = abs($end - $start);

        $interval->s = $seconds - $antiseconds;
        $interval->u = $microseconds;
        $interval->invert = $absolute ? false : $negative;

        return $interval;
    }
396271
public function diffInYears(Date $dt = null, $abs = true)
    {
        $dt = $dt ?: static::now($this->getTimezone());

        return (int) $this->diff($dt, $abs)->format('%r%y');
    }
504192
public function diffAsCarbonInterval($date = null, $absolute = true)
    {
        return CarbonInterval::instance($this->diff($this->resolveCarbon($date), $absolute));
    }
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;
	}
65443
public function diffInWeekendDays($date = null, $absolute = true)
    {
        return $this->diffInDaysFiltered(function (CarbonInterface $date) {
            return $date->isWeekend();
        }, $date, $absolute);
    }
555379
public function avg($callback = null)
    {
        $count = $this->count();

        return $count ? $this->sum($callback) / $count : null;
    }
644937
public function diff(Time $time, $absolute = true)
    {
        $diff = $this->getSeconds() - $time->getSeconds();

        return new self(0, 0, $absolute ? abs($diff) : $diff);
    }
1325756
def diff(self, dt=None, abs=True):
        
        if dt is None:
            dt = self.now(self.tz)

        return Period(self, dt, absolute=abs)
612535
def diff(self, dt=None, abs=True):
        
        if dt is None:
            dt = self.today()

        return Period(self, Date(dt.year, dt.month, dt.day), absolute=abs)
1278182
public function average($callback = null)
    {
        if ($count = $this->count()) {
            return $this->sum($callback) / $count;
        }
    }
310240
function dob() {return dfc($this, function() {
		/** @var \DateTime|null $r */
		if (!($r = $this->_dob()) && df_is_customer_attribute_required('dob')) {
			$r = new \DateTime;
			$r->setDate(1900, 1, 1);
		}
		return $r;
	});}
76456
public static function compareDateIntervals(DateInterval $a, DateInterval $b)
    {
        $current = Carbon::now();
        $passed = $current->copy()->add($b);
        $current->add($a);

        if ($current < $passed) {
            return -1;
        } elseif ($current > $passed) {
            return 1;
        }

        return 0;
    }
856077
public function getDateInterval()
    {
        if ( !$this->from && !$this->to ) {
            return null;
        }
        return $this->from->diff($this->to);
    }