Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,14 @@ public static int compareXSDDateTime(NodeValue nv1, NodeValue nv2) {
/** Return a XMLGregorianCalendar appropriate for XSD comparision */
private static XMLGregorianCalendar getXMLGregorianCalendarXSD(NodeValue nv) {
XMLGregorianCalendar dt = nv.getDateTime();
if ( nv.isDate()) {
// Force time so that the starting instants are compared.
// Without a time, the timezone normalization compares the UTC calendar day.
dt.setHour(0);
dt.setMinute(0);
dt.setSecond(0);
return dt;
}
if ( nv.isTime()) {
if ( dt.getHour() == 24 )
// Normalize "24:00:00"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,21 @@ public void testCompare23() {
assertThrows(ExprNotComparableException.class, ()->NodeValue.compare(nv1, nv2));
}

@Test public void testCompare24() {
// GH-4299 : Dates compare by their starting instants.
// Same calendar day after normalization to UTC, starting instants one hour apart.
NodeValue nv1 = NodeValue.makeDate("2026-01-01+01:00");
NodeValue nv2 = NodeValue.makeDate("2026-01-01+02:00");
assertEquals(NodeValue.CMP_GREATER, NodeValue.compare(nv1, nv2), "Does not compare " + nv1 + " & " + nv2);
}

@Test public void testCompare25() {
// GH-4299 : Dates compare by their starting instants.
NodeValue nv1 = NodeValue.makeDate("2026-01-02+14:00");
NodeValue nv2 = NodeValue.makeDate("2026-01-01-14:00");
assertEquals(NodeValue.CMP_LESS, NodeValue.compare(nv1, nv2), "Does not compare " + nv1 + " & " + nv2);
}

@Test public void testSameUnknown_1() {
NodeValue nv1 = NodeValue.makeNode(NodeFactory.createURI("test:abc"));
NodeValue nv2 = NodeValue.makeNode(NodeFactory.createURI("test:abc"));
Expand Down Expand Up @@ -624,6 +639,15 @@ public void testSameUnknown_3() {
assertFalse(NodeValue.notSameValueAs(nv1, nv2));
}

@Test public void testSameDate_4() {
// GH-4299 : Same calendar day after normalization to UTC, different starting instants.
NodeValue nv1 = NodeValue.makeDate("2026-01-01+01:00");
NodeValue nv2 = NodeValue.makeDate("2026-01-01+02:00");

assertFalse(NodeValue.sameValueAs(nv1, nv2));
assertTrue(NodeValue.notSameValueAs(nv1, nv2));
}

@Test public void testSameDate_3() {
NodeValue nv1 = NodeValue.makeDate("2007-09-04Z");
NodeValue nv2 = NodeValue.makeDate("2007-09-04"); // No timezone
Expand Down