pjfanning opened a new pull request, #157:
URL: https://github.com/apache/poi-xmlbeans/pull/157

   Follow-up to #153.
   
   `JavaGDurationHolderEx.equal_to` uses `compareToGDuration`, whose slow path 
adds both durations to the four schema reference dates. Every 400 Gregorian 
years is exactly 146097 days whatever the start date, so `P400Y` and `P146097D` 
compare equal. But `value_hash_code` hashed the month total (4800 vs 0), so 
equal values got different hash codes, and an `xs:unique` over them missed the 
duplicate.
   
   I checked every month offset in ±9600 against the four reference dates 
(1696-09-01, 1697-02-01, 1903-03-01, 1903-07-01): only multiples of 4800 span 
the same number of days from all four. So folding whole 4800-month blocks into 
seconds (146097 × 86400 each, with `floorDiv`/`floorMod` so negative totals 
work) makes the hash agree with `equal_to`.
   
   `stripTrailingZeros` now runs after the fold, because `BigDecimal.hashCode` 
depends on scale.
   
   Regression test `fourHundredYearCycleHashesEqual` added to 
`DurationIdentityConstraintValidateTest` (positive, negative, mixed months, 
fractional seconds, 800 years, plus an off-by-one-day negative case). It fails 
without the change and passes with it.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to