[ 
https://issues.apache.org/jira/browse/JENA-1402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16740821#comment-16740821
 ] 

Greg Albiston commented on JENA-1402:
-------------------------------------

I've had a quick look at _NodeValueDuration_ and where it is used in the ARQ 
module.

In _XSDFuncOp,_ there are checks to get and set fields (i.e. year, month) which 
aren't explicit on the _java.time.Duration_ as it only goes up to days. 
Converting days to months and years consistently could be problematic without a 
start date for context.

In _CastXSD,_ there are checks against the _xml.Duration_ fields for building 
new durations of type _xdt:dayTimeDuration_ or _xdt:yearMonthDuration_ (these 
aren't explicit in _java.time.Duration_). Same issue as above in distinguishing 
when x days becomes y months.

In _NodeValueOps,_ there are operations using _XMLGregorianCalendar_ for which 
_java.time.Duration_ doesn't have methods. _java.time.__LocalTime_ and 
_java.time.__OffsetTime_ can be built from parsing the 
_XMLGregorianCalendar.toString()_ but need to be selected based on whether 
there is a TimeZone offset. _LocalTime/__OffsetTime_ could then be used to 
operate on the _java.time.Duration._

So it could be quite difficult to swap to _java.time.Duration_ and retain the 
XML Datatype functionality. Perhaps the extra classes or approach Bruno 
mentioned might help.

> Subtracting two xsd:Duration gives incorrect results in SPARQL query
> --------------------------------------------------------------------
>
>                 Key: JENA-1402
>                 URL: https://issues.apache.org/jira/browse/JENA-1402
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: ARQ
>    Affects Versions: Jena 3.4.0
>            Reporter: Greg Albiston
>            Priority: Major
>
> There is an issue when subtracting two xsd:durations that include:
> * decimal seconds
> * non-zero minutes
> * second operand has a greater number of seconds than the first operand, i.e. 
> the minutes are reduced. 
> The result is a large number of minutes and incorrect seconds.
> For example:
> Integer, Larger: "PT2M3S" - "PT1M10S"  = "PT0M53S" CORRECT
> Decimal, Smaller: "PT2M3.123S" - "PT1M1.123S" = "PT1M2.000S" CORRECT
> Decimal, Larger, Seconds: "PT0M3.123S" - "PT1M10.123S"  = "-PT1M7.000S" 
> CORRECT
> Decimal, Larger, Minutes: "PT2M3.123S" - "PT1M10.123S"  = "PT883M0.020S" 
> INCORRECT
> Decimal, Larger, Hours: "PT1H4M3.123S" - "PT0M10.123S" = "PT1H3883M0.020S" 
> INCORRECT
> Example SPARQL:
> {code:sparql}
> SELECT ?res ?op1 ?op2
> WHERE{
>    VALUES (?op1 ?op2) {
>         ("PT2M3S"^^<http://www.w3.org/2001/XMLSchema#duration> 
> "PT1M10S"^^<http://www.w3.org/2001/XMLSchema#duration>)
>         ("PT2M3.123S"^^<http://www.w3.org/2001/XMLSchema#duration> 
> "PT1M1.123S"^^<http://www.w3.org/2001/XMLSchema#duration>)
>         ("PT0M3.123S"^^<http://www.w3.org/2001/XMLSchema#duration> 
> "PT1M10.123S"^^<http://www.w3.org/2001/XMLSchema#duration>)
>         ("PT2M3.123S"^^<http://www.w3.org/2001/XMLSchema#duration> 
> "PT1M10.123S"^^<http://www.w3.org/2001/XMLSchema#duration>)
>         ("PT1H4M3.123S"^^<http://www.w3.org/2001/XMLSchema#duration> 
> "PT0M10.123S"^^<http://www.w3.org/2001/XMLSchema#duration>)
>     }
>     BIND(?op1 - ?op2 AS ?res)
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to