Sets the current date to the nearest or next workday.

Sunday always becomes monday.

@param  string  $next  if <code>true</code> saturday becomes monday, otherwise friday.
@return DateTime
480659
public function forceWorkday($next = false)
	{
		$weekday = $this->format('N');
		if ($weekday == 7) $this->addDays(1);
		elseif ($weekday == 6) $next ? $this->addDays(2) : $this->addDays(-1);
		return $this;
	}
651756
private function nextOrPreviousDay($weekday = true, $forward = true)
    {
        $step = $forward ? 1 : -1;

        do {
            $this->addDay($step);
        } while ($weekday ? $this->isWeekend() : $this->isWeekday());

        return $this;
    }
712147
static public function nextSameWeekday($time) {
        $originalTime = strtotime($time);
        $nextWeekdayText = date("l");
        $nextWeekday = strtotime("next " . $nextWeekdayText);
        return strtotime(date("Y-m-d", $nextWeekday) . " " . date("H:i:s", $originalTime));
    }
905696
public function setMin(string $min) : Datetime
    {
        $min = date($this->format, strtotime($min));
        $this->attributes['min'] = $min;
        return $this->addTest('min', function ($value) use ($min) {
            return $value >= $min;
        });
    }
115649
def nearest_workday(dt):
    
    if dt.weekday() == 5:
        return dt - timedelta(1)
    elif dt.weekday() == 6:
        return dt + timedelta(1)
    return dt
692627
public function setISODate($year, $week, $day = 1) : \DateTime /*self invariant*/
    {
        if ($this->frozen) {
            throw new \RuntimeException(get_class($this) . ' is read-only, frozen.');
        }
        return parent::setIsoDate($year, $week, $day);
    }
819748
protected function nextDaily()
    {
        if (!$this->byHour && !$this->byDay) {
            $this->currentDate = $this->currentDate->modify('+'.$this->interval.' days');

            return;
        }

        if (!empty($this->byHour)) {
            $recurrenceHours = $this->getHours();
        }

        if (!empty($this->byDay)) {
            $recurrenceDays = $this->getDays();
        }

        if (!empty($this->byMonth)) {
            $recurrenceMonths = $this->getMonths();
        }

        do {
            if ($this->byHour) {
                if ('23' == $this->currentDate->format('G')) {
                    // to obey the interval rule
                    $this->currentDate = $this->currentDate->modify('+'.($this->interval - 1).' days');
                }

                $this->currentDate = $this->currentDate->modify('+1 hours');
            } else {
                $this->currentDate = $this->currentDate->modify('+'.$this->interval.' days');
            }

            // Current month of the year
            $currentMonth = $this->currentDate->format('n');

            // Current day of the week
            $currentDay = $this->currentDate->format('w');

            // Current hour of the day
            $currentHour = $this->currentDate->format('G');
        } while (
            ($this->byDay && !in_array($currentDay, $recurrenceDays)) ||
            ($this->byHour && !in_array($currentHour, $recurrenceHours)) ||
            ($this->byMonth && !in_array($currentMonth, $recurrenceMonths))
        );
    }
1003764
public function endOfWeek()
    {
        if ($this->getDayOfWeek() !== static::$weekEndsAt) {
            return $this->next(static::$weekEndsAt)->endOfDay();
        }

        return $this->endOfDay();
    }
1191055
public function dayNumber(String $dayNumber = '*') : Job
    {
        $this->dayNumber = $this->_slashes($dayNumber);

        return $this;
    }
814957
private function nextOrPreviousDay($weekday = true, $forward = true)
    {
        /** @var CarbonInterface $step */
        $date = $this;
        $step = $forward ? 1 : -1;

        do {
            $date = $date->addDays($step);
        } while ($weekday ? $date->isWeekend() : $date->isWeekday());

        return $date;
    }
638414
public function setNextTimeout($next = null)
    {
        if ($next != null) {
            $this->nextExpiration = $next;
        } else {
            $this->nextExpiration = null;
        }
    }
1373059
public function startOfWeek()
        {
            if ($this->dayOfWeek != self::MONDAY) $this->previous(self::MONDAY);

            return $this->startOfDay();
        }
54825
public function endOfWeek()
        {
            if ($this->dayOfWeek != self::SUNDAY) $this->next(self::SUNDAY);

            return $this->endOfDay();
        }
1200223
public function setFrequency(int $value) : ScheduledJob
    {

        if ($this->data['frequency'] !== $value) {
            $this->data['frequency'] = $value;
            $this->setModified('frequency');
        }

        return $this;
    }
767306
public function setISODate($year, $week, $day = 1)
	{
		if ($this->datetime->setISODate($year, $week, $day))
		{
			return $this;
		}

		return false;
	}
591359
public function setCurrentJob($value) : ScheduledJob
    {
        // Is this a scalar value representing the ID of this foreign key?
        if (is_scalar($value)) {
            return $this->setCurrentJobId($value);
        }

        // Is this an instance of CurrentJob?
        if (is_object($value) && $value instanceof Job) {
            return $this->setCurrentJobObject($value);
        }

        // Is this an array representing a Job item?
        if (is_array($value) && !empty($value['id'])) {
            return $this->setCurrentJobId($value['id']);
        }

        // None of the above? That's a problem!
        throw new \Exception('Invalid value for CurrentJob.');
    }
216533
public function setValue($value)
    {
        if ($value instanceof DateInterval) {
            $value = Utils::now()->add($value);
        }

        if ($value instanceof DateTimeInterface) {
            $value = $value->getTimestamp();
        }

        return parent::setValue($value);
    }