src/DateRange.php
public function spans($time_period)
    {
        $time_period = self::parseTimePeriod($time_period);

        // If the date range does not have a bound then it will not span any time periods.
        if (! $this->isBounded()) {
            return false;
        }

        // After must be positioned at the end of the time period
        $end = self::forTimePeriod($time_period, $this->after)->end();
        if (! $end->eq($this->after)) {
            return;
        }

        // Before must be positioned at the start of the time period
        $start = self::forTimePeriod($time_period, $this->before)->start();
        if (! $start->eq($this->before)) {
            return;
        }

        // The start of the date range should equal the end of the date range set back to the start of its time period.
        // This ensures that the range spans only a single time period; otherwise if we only checked the bounds, they
        // could be two or more time periods apart.
        if (! self::forTimePeriod($time_period, $this->end())->start()->eq($this->start())) {
            return;
        }

        return $this->start();
    }
public function spans($time_period)
    {
        $time_period = self::parseTimePeriod($time_period);

        // If the date range does not have a bound then it will not span any time periods.
        if (! $this->isBounded()) {
            return false;
        }

        // After must be positioned at the end of the time period
        $end = self::forTimePeriod($time_period, $this->after)->end();
        if (! $end->eq($this->after)) {
            return;
        }

        // Before must be positioned at the start of the time period
        $start = self::forTimePeriod($time_period, $this->before)->start();
        if (! $start->eq($this->before)) {
            return;
        }

        // The start of the date range should equal the end of the date range set back to the start of its time period.
        // This ensures that the range spans only a single time period; otherwise if we only checked the bounds, they
        // could be two or more time periods apart.
        if (! self::forTimePeriod($time_period, $this->end())->start()->eq($this->start())) {
            return;
        }

        return $this->start();
    }
public function spans ( $ time_period ) { $ time_period = self :: parseTimePeriod ( $ time_period ) ; // If the date range does not have a bound then it will not span any time periods. if ( ! $ this -> isBounded ( ) ) { return false ; } // After must be positioned at the end of the time period $ end = self :: forTimePeriod ( $ time_period , $ this -> after ) -> end ( ) ; if ( ! $ end -> eq ( $ this -> after ) ) { return ; } // Before must be positioned at the start of the time period $ start = self :: forTimePeriod ( $ time_period , $ this -> before ) -> start ( ) ; if ( ! $ start -> eq ( $ this -> before ) ) { return ; } // The start of the date range should equal the end of the date range set back to the start of its time period. // This ensures that the range spans only a single time period; otherwise if we only checked the bounds, they // could be two or more time periods apart. if ( ! self :: forTimePeriod ( $ time_period , $ this -> end ( ) ) -> start ( ) -> eq ( $ this -> start ( ) ) ) { return ; } return $ this -> start ( ) ; }
Determines if a date range spans exactly one entire time period.

@param $time_period
@return Carbon|boolean The beginning of the time period, or null.
Determines if a date range spans exactly one entire time period .