resultA = compareOrder (date1, date2); short baseResult = resultA; // Full comparison including time fractions if ( resultA == 0 ) { int[] tempA = addDuration (date1, 0, fDuration[0]); int[] tempB = addDuration (date2, 0, fDuration[1]); resultA = compareOrder(tempA, tempB); if ( resultA == INDETERMINATE ) { return INDETERMINATE; tempA = addDuration(date1, 1, fDuration[0]); tempB = addDuration(date2, 1, fDuration[1]); resultB = compareOrder(tempA, tempB); resultA = compareResults(resultA, resultB, strict); if (resultA == INDETERMINATE) { return INDETERMINATE; tempA = addDuration(date1, 2, fDuration[0]); tempB = addDuration(date2, 2, fDuration[1]); resultB = compareOrder(tempA, tempB); resultA = compareResults(resultA, resultB, strict); if (resultA == INDETERMINATE) { return INDETERMINATE; tempA = addDuration(date1, 3, fDuration[0]); tempB = addDuration(date2, 3, fDuration[1]); resultB = compareOrder(tempA, tempB); resultA = compareResults(resultA, resultB, strict);
resetDateObj(duration); duration[M] = modulo (temp, 1, 13); int carry = fQuotient (temp, 1, 13); carry = fQuotient (temp, 60); duration[s] = mod(temp, 60, carry); carry = fQuotient (temp, 60); duration[m]= mod(temp, 60, carry); carry = fQuotient(temp, 24); duration[h] = mod(temp, 24, carry); temp=maxDayInMonthFor(duration[CY], duration[M]); if ( duration[D] < 1 ) { //original duration was negative duration[D] = duration[D] + maxDayInMonthFor(duration[CY], duration[M]-1); carry=-1; duration[M] = modulo(temp, 1, 13); duration[CY] = duration[CY]+fQuotient(temp, 1, 13);
public NodeValueDuration(XSDDuration dt) { duration = dt ; if (dt.getDays() != 0 && dt.getMonths() !=0 && dt.getYears() != 0) { throw new ExprException("Illegal time: "+dt) ; } if ( dt.getTimePart() == 0 ) throw new ExprException("Illegal time: "+dt) ; }
/** * Return the time component of the duration - i.e. just the hours/mins/seconds, * and returns the values in seconds. */ public double getTimePart() { return ((data[h]) * 60l + data[m]) * 60l + getSeconds(); }
private static int compareXSDDuration(XSDDuration duration1 , XSDDuration duration2) { // Returns codes are -1/0/1 but also 2 for "Indeterminate" // Not fully sure when Indeterminate is returned with regards to a duration int x = duration1.compare(duration2) ; if ( x == XSDDuration.EQUAL ) return Expr.CMP_EQUAL ; if ( x == XSDDuration.LESS_THAN ) return Expr.CMP_LESS ; if ( x == XSDDuration.GREATER_THAN ) return Expr.CMP_GREATER ; if ( x == XSDDuration.INDETERMINATE ) return Expr.CMP_INDETERMINATE ; throw new ARQInternalErrorException("Unexpected return from XSDDuration.compare: "+x) ; }
return new XSDDuration(date);