From a252bcce13f33ceab119fa931b2dac9a24c7a630 Mon Sep 17 00:00:00 2001 From: Andrew Fechser <82467216+afechser-bamboo@users.noreply.github.com> Date: Wed, 29 Dec 2021 20:35:49 -0700 Subject: [PATCH] Update CronExpression.php If the DayOfMonth is set to L the usort reorders the $combined and then $nth points to the current date instead of the last day of the month. --- src/Cron/CronExpression.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Cron/CronExpression.php b/src/Cron/CronExpression.php index 994c1147..89992954 100644 --- a/src/Cron/CronExpression.php +++ b/src/Cron/CronExpression.php @@ -390,9 +390,11 @@ protected function getRunDate($currentTime = null, int $nth = 0, bool $invert = $dowRunDates = $dowExpression->getMultipleRunDates($nth + 1, $currentTime, $invert, $allowCurrentDate, $timeZone); $combined = array_merge($domRunDates, $dowRunDates); - usort($combined, function ($a, $b) { - return $a->format('Y-m-d H:i:s') <=> $b->format('Y-m-d H:i:s'); - }); + if ($parts[2] !== 'L') { + usort($combined, function ($a, $b) { + return $a->format('Y-m-d H:i:s') <=> $b->format('Y-m-d H:i:s'); + }); + } return $combined[$nth]; }