private function parseTime($time)
    {
        $timezone = $this->config->get('app.timezone', 'UTC');

        /** @var Carbon $now */
        $now = Carbon::now($timezone);

        if (is_object($time)) {
            $deliveryTime = Carbon::instance($time);
        } else {
            if (is_array($time)) {
                reset($time);
                $type = key($time);
                $amount = $time[$type];
            } else {
                $type = 'seconds';
                $amount = $time;
            }

            /** @var Carbon $deliveryTime */
            $deliveryTime = Carbon::now($timezone);

            switch ($type) {
                case 'seconds':
                    $deliveryTime->addSeconds($amount);
                    break;
                case 'minutes':
                    $deliveryTime->addMinutes($amount);
                    break;
                case 'hours':
                    $deliveryTime->addHours($amount);
                    break;
                case 'days':
                    $deliveryTime->addHours($amount * 24);
                    break;
                default:
                    $deliveryTime->addSeconds($amount);
                    break;
            }
        }

        //Calculate boundaries
        $max = Carbon::now()->addHours(3 * 24);
        if ($deliveryTime->gt($max)) {
            $deliveryTime = $max;
        } elseif ($deliveryTime->lt($now)) {
            $deliveryTime = $now;
        }

        return $deliveryTime->format(\DateTime::RFC2822);
    }
private function parseTime($time)
    {
        $timezone = $this->config->get('app.timezone', 'UTC');

        /** @var Carbon $now */
        $now = Carbon::now($timezone);

        if (is_object($time)) {
            $deliveryTime = Carbon::instance($time);
        } else {
            if (is_array($time)) {
                reset($time);
                $type = key($time);
                $amount = $time[$type];
            } else {
                $type = 'seconds';
                $amount = $time;
            }

            /** @var Carbon $deliveryTime */
            $deliveryTime = Carbon::now($timezone);

            switch ($type) {
                case 'seconds':
                    $deliveryTime->addSeconds($amount);
                    break;
                case 'minutes':
                    $deliveryTime->addMinutes($amount);
                    break;
                case 'hours':
                    $deliveryTime->addHours($amount);
                    break;
                case 'days':
                    $deliveryTime->addHours($amount * 24);
                    break;
                default:
                    $deliveryTime->addSeconds($amount);
                    break;
            }
        }

        //Calculate boundaries
        $max = Carbon::now()->addHours(3 * 24);
        if ($deliveryTime->gt($max)) {
            $deliveryTime = $max;
        } elseif ($deliveryTime->lt($now)) {
            $deliveryTime = $now;
        }

        return $deliveryTime->format(\DateTime::RFC2822);
    }
private function parseTime ( $ time ) { $ timezone = $ this -> config -> get ( 'app.timezone' , 'UTC' ) ; /** @var Carbon $now */ $ now = Carbon :: now ( $ timezone ) ; if ( is_object ( $ time ) ) { $ deliveryTime = Carbon :: instance ( $ time ) ; } else { if ( is_array ( $ time ) ) { reset ( $ time ) ; $ type = key ( $ time ) ; $ amount = $ time [ $ type ] ; } else { $ type = 'seconds' ; $ amount = $ time ; } /** @var Carbon $deliveryTime */ $ deliveryTime = Carbon :: now ( $ timezone ) ; switch ( $ type ) { case 'seconds' : $ deliveryTime -> addSeconds ( $ amount ) ; break ; case 'minutes' : $ deliveryTime -> addMinutes ( $ amount ) ; break ; case 'hours' : $ deliveryTime -> addHours ( $ amount ) ; break ; case 'days' : $ deliveryTime -> addHours ( $ amount * 24 ) ; break ; default : $ deliveryTime -> addSeconds ( $ amount ) ; break ; } } //Calculate boundaries $ max = Carbon :: now ( ) -> addHours ( 3 * 24 ) ; if ( $ deliveryTime -> gt ( $ max ) ) { $ deliveryTime = $ max ; } elseif ( $ deliveryTime -> lt ( $ now ) ) { $ deliveryTime = $ now ; } return $ deliveryTime -> format ( \ DateTime :: RFC2822 ) ; }
Parse given time and convert it to the required format

@param int|array|Carbon|\DateTime $time

@return string
Parse given time and convert it to the required format