Skip to content

Commit

Permalink
adds onlyWeekDays and getNextRunDate
Browse files Browse the repository at this point in the history
  • Loading branch information
leobeal committed May 6, 2019
1 parent 5c7c827 commit dcd0cd2
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/Jobs/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ public function monthly(): self
return $this;
}

/**
* Sets the cron to work just on week days
* @return $this
*/
public function onlyWeekDays(): self
{
$this->cron->setPart(4, "1-5");
return $this;
}

/**
* @param int $value
* @param int $position
Expand Down Expand Up @@ -177,22 +187,23 @@ public function setExpression(string $expression = "* * * * *"): self
/**
* Return true if the schedule is due to now
* @param $currentTime
* @param string $timeZone
* @return bool
*/
public function isDue($currentTime = 'now'): bool
public function isDue($currentTime = 'now', string $timeZone = "Europe/Berlin"): bool
{
return $this->cron->isDue($currentTime);
return $this->cron->isDue($currentTime, $timeZone);
}

/**
* Sets whether the job should run on just one instance
* @param bool $decision
* @return $this
* Return the next run date
* @param $currentTime
* @param string $timeZone
* @return \DateTime
*/
public function shouldRunOnOnlyOneInstance(bool $decision = true): self
public function getNextRunDate($currentTime = 'now', string $timeZone = "Europe/Berlin"): \DateTime
{
$this->shouldRunOnOnlyOneServer = $decision;
return $this;
return $this->cron->getNextRunDate($currentTime, 0, false, $timeZone);
}

/**
Expand Down

0 comments on commit dcd0cd2

Please sign in to comment.