Fix for issue #629 - Arithmetic Operations of DateTime in SPARQL by Akash-Sharma-1 · Pull Request #1061 · RDFLib/rdflib (original) (raw)
Added the functionality for performing arithmetic operations of DateTime/Date/Time in SPARQL Queries.
This will fix the issue of #629 which requires handling of the arithmetic operation of dateTime
variables in the SPARQL query. This fix also extends this operation handling to other similar Date, Time, Duration based variables. These operations are also discussed in official w3c Sparql work - (https://github.com/w3c/sparql-12/blob/master/SEP/SEP-0002/sep-0002.md)
This is the list of handled operations :
- xsd:dateTime - xsd:dateTime
- xsd:date - xsd:date
- xsd:time - xsd:time
- xsd:dateTime - (xsd:dayTimeDuration or xsd:yearMonthDuration or xsd:duration)
- xsd:dateTime + (xsd:dayTimeDuration or xsd:yearMonthDuration or xsd:duration)
- xsd:date - (xsd:dayTimeDuration or xsd:yearMonthDuration or xsd:duration)
- xsd:date + (xsd:dayTimeDuration or xsd:yearMonthDuration or xsd:duration)
- xsd:time - (xsd:dayTimeDuration or xsd:duration)
- xsd:time + (xsd:dayTimeDuration or xsd:duration)
In this PR, I have added the code to handle these operations in SPARQL queries. I have also added tests for the same operations. (Some test cases were also taken from (https://github.com/kasei/sparql-12/tree/xsd_datetime_duration/tests/xsd_functions)).
Closes #629