fix: skip short months for nW day-of-month (#715) - #720
Open
arimu1 wants to merge 1 commit into
Open
Conversation
Guard OnDayOfMonthValueGenerator W when day exceeds month length so LocalDate.of no longer throws DateTimeException (e.g. 31W in June). Also use Friday when n falls on the last day and is Sunday, matching Quartz nearest-weekday behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #715
nW(nearest weekday to the nth of the month) threwDateTimeExceptionwhen the candidate month was shorter thann(e.g.31Win June), becauseOnDayOfMonthValueGeneratorcalledLocalDate.of(year, month, dayOfMonth)before checking month length.Changes
dayOfMonth > lengthOfMonth, throwNoSuchValueExceptionso the scheduler skips that month (same approach as theLbranch, and aligned with Quartz).nis the last day of a long month and falls on Sunday, resolve to Friday (n - 2) so weekday adjustment matches Quartz (e.g.2025-08-31→2025-08-29).Reproduction (now fixed)
Test plan
OnDayOfMonthValueGeneratorWTest— short-month no-value + last-day Sunday → FridayIssue715Test— Quartz31Wsequence matches reference; SPRING53 skips June