Skip to content

Skip nonexistent day-of-month targets for W schedules - #229

Open
MelnixDev wants to merge 1 commit into
dragonmantank:masterfrom
MelnixDev:fix/weekday-short-month-overflow
Open

MelnixDev wants to merge 1 commit into
dragonmantank:masterfrom
MelnixDev:fix/weekday-short-month-overflow

Conversation

@MelnixDev

Copy link
Copy Markdown

Fixes #228.

31W currently matches April 1, 2023, a Saturday. PHP normalizes April 31 to May 1; the nearest-weekday helper accepts that Monday, and matching then compares only its day number against April's dates.

Before constructing the target date, reject a W target above the current month's final day. Months without that date are skipped, as with ordinary day-of-month matching. Existing valid W dates keep their weekend adjustment behavior. The production change is four lines in DayOfMonthField::isSatisfiedBy().

The new tests cover every day of selected 28-, 29- and 30-day months for nonexistent W targets, plus valid leap-day and weekend-adjustment controls. Integration coverage checks isDue(), next/previous dates, and multiple runs. Both the field and integration regressions fail on the original code.

Verified locally on PHP 8.4.27 / macOS:

  • Full PHPUnit 12.5.44 suite: 180 tests, 1,062 assertions, four skipped, no failures.
  • PHPStan 2.3.5 with the repository configuration: no errors; run in debug mode to avoid worker processes.
  • git diff --check: passes.

Other PHP versions, coverage collection and the legacy PHP-CS-Fixer configuration were not run. This corrects the dates produced by affected W expressions in short months; no new cron syntax or dependencies are introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

31W can schedule on the first day of a short month, including weekends

1 participant