You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2020/12/11 19:54:41 UTC

[GitHub] [jena] kinow commented on a change in pull request #885: Several tickets: JENA-2011 : JENA-2013 : JENA-2014

kinow commented on a change in pull request #885:
URL: https://github.com/apache/jena/pull/885#discussion_r541220531



##########
File path: jena-core/src/main/java/org/apache/jena/ext/xerces/jaxp/datatype/DurationImpl.java
##########
@@ -832,42 +832,45 @@ public int compare(Duration rhs) {
 					);
     	}
 
-    	// turn this Duration into a GregorianCalendar
-    	GregorianCalendar lhsCalendar = new GregorianCalendar(
-    			1970,
-				1,
-				1,
-				0,
-				0,
-				0);
-   		lhsCalendar.add(GregorianCalendar.YEAR, getYears() * getSign());
-   		lhsCalendar.add(GregorianCalendar.MONTH, getMonths() * getSign());
-   		lhsCalendar.add(GregorianCalendar.DAY_OF_YEAR, getDays() * getSign());
-   		lhsCalendar.add(GregorianCalendar.HOUR_OF_DAY, getHours() * getSign());
-   		lhsCalendar.add(GregorianCalendar.MINUTE, getMinutes() * getSign());
-   		lhsCalendar.add(GregorianCalendar.SECOND, getSeconds() * getSign());
-   		
-   		// turn compare Duration into a GregorianCalendar
-    	GregorianCalendar rhsCalendar = new GregorianCalendar(
-				1970,
-				1,
-				1,
-				0,
-				0,
-				0);
-   		rhsCalendar.add(GregorianCalendar.YEAR, rhs.getYears() * rhs.getSign());
-   		rhsCalendar.add(GregorianCalendar.MONTH, rhs.getMonths() * rhs.getSign());
-   		rhsCalendar.add(GregorianCalendar.DAY_OF_YEAR, rhs.getDays() * rhs.getSign());
-   		rhsCalendar.add(GregorianCalendar.HOUR_OF_DAY, rhs.getHours() * rhs.getSign());
-   		rhsCalendar.add(GregorianCalendar.MINUTE, rhs.getMinutes() * rhs.getSign());
-   		rhsCalendar.add(GregorianCalendar.SECOND, rhs.getSeconds() * rhs.getSign());
-   	
-   		
-   		if (lhsCalendar.equals(rhsCalendar)) {
-   			return DatatypeConstants.EQUAL;
-   		}
-
-   		return compareDates(this, rhs);
+    	if ( rhsSecondsAsBigDecimal == null || seconds == null ) {
+    	    // Jena: change: this only works for durations with no fractional seconds.
+    	    // Fix is to only use if no seconds in LHS or RHS.
+    	    
+    	    // turn this Duration into a GregorianCalendar
+    	    GregorianCalendar lhsCalendar = new GregorianCalendar(
+    	        1970,
+    	        1,
+    	        1,
+    	        0,
+    	        0,
+    	        0);
+    	    lhsCalendar.add(GregorianCalendar.YEAR, getYears() * getSign());
+    	    lhsCalendar.add(GregorianCalendar.MONTH, getMonths() * getSign());
+    	    lhsCalendar.add(GregorianCalendar.DAY_OF_YEAR, getDays() * getSign());
+    	    lhsCalendar.add(GregorianCalendar.HOUR_OF_DAY, getHours() * getSign());
+    	    lhsCalendar.add(GregorianCalendar.MINUTE, getMinutes() * getSign());
+    	    lhsCalendar.add(GregorianCalendar.SECOND, getSeconds() * getSign());
+
+    	    // turn compare Duration into a GregorianCalendar
+    	    GregorianCalendar rhsCalendar = new GregorianCalendar(
+    	        1970,
+    	        1,
+    	        1,
+    	        0,
+    	        0,
+    	        0);
+    	    rhsCalendar.add(GregorianCalendar.YEAR, rhs.getYears() * rhs.getSign());
+    	    rhsCalendar.add(GregorianCalendar.MONTH, rhs.getMonths() * rhs.getSign());
+    	    rhsCalendar.add(GregorianCalendar.DAY_OF_YEAR, rhs.getDays() * rhs.getSign());
+    	    rhsCalendar.add(GregorianCalendar.HOUR_OF_DAY, rhs.getHours() * rhs.getSign());
+    	    rhsCalendar.add(GregorianCalendar.MINUTE, rhs.getMinutes() * rhs.getSign());
+    	    rhsCalendar.add(GregorianCalendar.SECOND, rhs.getSeconds() * rhs.getSign());
+
+    	    if (lhsCalendar.equals(rhsCalendar)) {
+    	        return DatatypeConstants.EQUAL;
+    	    }
+    	}
+   		return compareDuration(this, rhs);

Review comment:
       Extra spaces?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org