Repository navigation
Conversation
getXMLGregorianCalendarXSD left xsd:date values without a time, so XMLGregorianCalendar.compare normalized the timezone on the date fields only and compared the UTC calendar day. Set the time to 00:00:00 for dates, as getXMLGregorianCalendarFO already does.
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.
GitHub issue resolved #4299
Pull request Description:
I started from #4299 and checked it against the code.
=,!=,<and>on twoxsd:datevalues go throughXSDFuncOp.compareDateTime, which (unlessStrictDateTimeFOis set) usescompareDateTimeXSDandgetXMLGregorianCalendarXSD. That method fixes upxsd:timeandxsd:dateTime(hour 24), but leavesxsd:dateas a calendar with no time fields.XMLGregorianCalendar.comparethen normalizes the timezone on the date fields only, which ends up comparing the UTC calendar day instead of the day's starting instant. So'2026-01-01+01:00'^^xsd:date = '2026-01-01+02:00'^^xsd:dateis true, while subtracting the two givesPT1H.getXMLGregorianCalendarFO, whichORDER BYuses throughcompareDateTimeFO, already sets the time to00:00:00for dates. This change adds the same block togetXMLGregorianCalendarXSD, so the operators compare starting instants, as F&O defines forop:date-equalandop:date-less-than. Comparing a date without a timezone to one with a timezone within 14 hours is still indeterminate (testCompare17).How I found it
I followed
NVCompare.sameValueAsandNVCompare.compareforVSPACE_DATEdown to the twogetXMLGregorianCalendar*methods and saw that only the F&O one handles dates. I then checked the JDK behaviour on its own: for the pairs in the issue,comparegivesEQUALon the date-only calendars andGREATER/LESSERonce hour, minute and second are set to 0.Where this can show up in practice
Data that records dates with timezone offsets, for example event days from several regions, or the same day exported by systems in different zones. A
FILTER(?d1 = ?d2)orFILTER(?d < ?cutoff)can then match pairs whose days start at different times, and the result can differ fromORDER BYon the same values, which already uses starting instants. This is my estimate beyond the report in #4299.Testing
TestXSDFuncOp:testCompare24andtestCompare25(the two pairs from the issue) andtestSameDate_4. Without the change toXSDFuncOp, all three fail. With it,TestXSDFuncOppasses.mvn -pl jena-arq test(Java 21, withjena-iri3986,jena-langtag,jena-baseandjena-coreinstalled first): 16895 tests, 0 failures, 0 errors, 1 skipped.StrictDateTimeFOset.By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.
See the Apache Jena "Contributing" guide.