-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a method to get run dates in a date range #41
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,12 +188,45 @@ public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrent | |
public function getMultipleRunDates($total, $currentTime = 'now', $invert = false, $allowCurrentDate = false) | ||
{ | ||
$matches = array(); | ||
for ($i = 0; $i < max(0, $total); $i++) { | ||
$guard_terminator = max(0, $total); | ||
for ($i = 0; $i < $guard_terminator; $i++) { | ||
$matches[] = $this->getRunDate($currentTime, $i, $invert, $allowCurrentDate); | ||
} | ||
|
||
return $matches; | ||
} | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The alignment of the comment is off here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be all good now. At least in my editor it shows all lined up the same. |
||
* Get ALL run dates limited to a date range | ||
* | ||
* @param string|DateTime $start Start of range | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* @param string|DateTime $end End of range | ||
* | ||
* @return array Returns an array of run dates | ||
*/ | ||
public function getRangeRunDates($start, $end) | ||
{ | ||
$matches = array(); | ||
|
||
if (!($end instanceof DateTime)) { | ||
$end = new DateTime($end ?: 'now'); | ||
$end->setTimezone(new DateTimeZone(date_default_timezone_get())); | ||
} | ||
|
||
if (!($start instanceof DateTime)) { | ||
$start = new DateTime($start ?: 'now'); | ||
$start->setTimezone(new DateTimeZone(date_default_timezone_get())); | ||
} | ||
|
||
for ( | ||
$guard = $this->getNextRunDate($start, 0, true); | ||
$guard <= $end; | ||
$guard = $this->getNextRunDate($guard, 0, false) | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add braces here? I don't like blocks without a wrapping brace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done :) |
||
$matches[] = $guard; | ||
|
||
return $matches; | ||
} | ||
|
||
/** | ||
* Get all or part of the CRON expression | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this just be changed to:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this and the suggestion of @TheDigitalOrchard above for $max