ActionScheduler_CronSchedule::__construct()publicWC 1.0

Wrapper for parent constructor to accept a cron expression string and map it to a CronExpression for this objects $recurrence property.

Метод класса: ActionScheduler_CronSchedule{}

Хуков нет.


null. Ничего.


$ActionScheduler_CronSchedule = new ActionScheduler_CronSchedule();
$ActionScheduler_CronSchedule->__construct( $start, $recurrence, $first );
$start(DateTime) (обязательный)
The date & time to run the action at or after. If $start aligns with the CronSchedule passed via $recurrence, it will be used. If it does not align, the first matching date after it will be used.
$recurrence(CronExpression|строка) (обязательный)
The CronExpression used to calculate the schedule's next instance.
(Optional) The date & time the first instance of this interval schedule ran.
По умолчанию: null, meaning this is the first instance

Код ActionScheduler_CronSchedule::__construct() WC 7.7.0

public function __construct( DateTime $start, $recurrence, DateTime $first = null ) {
	if ( ! is_a( $recurrence, 'CronExpression' ) ) {
		$recurrence = CronExpression::factory( $recurrence );

	// For backward compatibility, we need to make sure the date is set to the first matching cron date, not whatever date is passed in. Importantly, by passing true as the 3rd param, if $start matches the cron expression, then it will be used. This was previously handled in the now deprecated next() method.
	$date = $recurrence->getNextRunDate( $start, 0, true );

	// parent::__construct() will set this to $date by default, but that may be different to $start now.
	$first = empty( $first ) ? $start : $first;

	parent::__construct( $date, $recurrence, $first );