src/DateRange.php
protected function getDatePositionIn(Carbon $date_time, $time_period)
    {
        // First we need to validate the time period.
        if (!array_key_exists($time_period, self::$time_periods)) {
            throw new \InvalidArgumentException('Time period must be one of the time periods listed in the class constants');
        }

        // Now we will check to see whether the date is positioned at the beginning of the time
        // period provided.
        $start_date = self::forTimePeriod($time_period, $date_time)->start();
        if ($date_time->copy()->eq($start_date)) {
            return self::START;
        }

        // Now we will check to see whether the date is positioned at the end of the time period
        // provided.
        $end_date = self::forTimePeriod($time_period, $date_time)->end();
        if ($date_time->copy()->eq($end_date)) {
            return self::END;
        }
    }
protected function getDatePositionIn(Carbon $date_time, $time_period)
    {
        // First we need to validate the time period.
        if (!array_key_exists($time_period, self::$time_periods)) {
            throw new \InvalidArgumentException('Time period must be one of the time periods listed in the class constants');
        }

        // Now we will check to see whether the date is positioned at the beginning of the time
        // period provided.
        $start_date = self::forTimePeriod($time_period, $date_time)->start();
        if ($date_time->copy()->eq($start_date)) {
            return self::START;
        }

        // Now we will check to see whether the date is positioned at the end of the time period
        // provided.
        $end_date = self::forTimePeriod($time_period, $date_time)->end();
        if ($date_time->copy()->eq($end_date)) {
            return self::END;
        }
    }
protected function getDatePositionIn ( Carbon $ date_time , $ time_period ) { // First we need to validate the time period. if ( ! array_key_exists ( $ time_period , self :: $ time_periods ) ) { throw new \ InvalidArgumentException ( 'Time period must be one of the time periods listed in the class constants' ) ; } // Now we will check to see whether the date is positioned at the beginning of the time // period provided. $ start_date = self :: forTimePeriod ( $ time_period , $ date_time ) -> start ( ) ; if ( $ date_time -> copy ( ) -> eq ( $ start_date ) ) { return self :: START ; } // Now we will check to see whether the date is positioned at the end of the time period // provided. $ end_date = self :: forTimePeriod ( $ time_period , $ date_time ) -> end ( ) ; if ( $ date_time -> copy ( ) -> eq ( $ end_date ) ) { return self :: END ; } }
Determines a dates position within a time period.

@param Carbon $date_time
@param $time_period

@return string|null A class constant that represents a time period, or null.
Determines a dates position within a time period .