sahvx655-wq opened a new pull request, #408:
URL: https://github.com/apache/commons-validator/pull/408

   compareWeeks reports 31 December and 1 January of the same calendar year as 
the same week. AbstractCalendarValidator.compare orders the WEEK_OF_YEAR field 
on Calendar.YEAR and then WEEK_OF_YEAR, but a week belongs to its own 
week-year, and at the turn of the year that week-year differs from the calendar 
year. Under the US locale 31 Dec 2018 has WEEK_OF_YEAR 1 and a week-year of 
2019, so against 1 Jan 2018 (also WEEK_OF_YEAR 1) the year and the week number 
both match and two dates roughly 52 weeks apart compare equal. The mirror case 
fails the other way: 31 Dec 2018 and 1 Jan 2019 share week 1 of week-year 2019 
yet compare as different weeks because their calendar years differ.
   
   The fix orders the WEEK_OF_YEAR comparison on the week-year from 
Calendar.getWeekYear(), falling back to Calendar.YEAR where the calendar does 
not support week dates, before comparing the week number, and leaves every 
other field untouched. compareQuarters already shifts its year at the quarter 
boundary, so this keeps the week comparison consistent with it. The added test 
fails on the current code and passes with the change.
   
   - [x] Read the [contribution guidelines](CONTRIBUTING.md) for this project.
   - [ ] Read the [ASF Generative Tooling 
Guidance](https://www.apache.org/legal/generative-tooling.html) if you use 
Artificial Intelligence (AI).
   - [ ] I used AI to create any part of, or all of, this pull request. Which 
AI tool was used to create this pull request, and to what extent did it 
contribute?
   - [x] Run a successful build using the default 
[Maven](https://maven.apache.org/) goal with `mvn`; that's `mvn` on the command 
line by itself.
   - [x] Write unit tests that match behavioral changes, where the tests fail 
if the changes to the runtime are not applied. This may not always be possible, 
but it is a best practice.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [x] Each commit in the pull request should have a meaningful subject line 
and body. Note that a maintainer may squash commits during the merge process.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to