Andy,
Thanks so much for this. I didn't know this was supported, and is exactly
what I need.


 - Steve

Steven R. Ray, Ph.D.
Distinguished Research Fellow
Carnegie Mellon University
NASA Research Park
Building 23 (MS 23-11)
P.O. Box 1
Moffett Field, CA 94305-0001
Email:   [email protected]
Phone: (650) 587-3780
Cell:     (202) 316-6481
Skype:  steverayconsulting

On Sun, Mar 5, 2017 at 1:56 AM, Andy Seaborne <[email protected]> wrote:

> Jena's SPARQL engine has support for calculation on dateTimes (it has all
> of XQuery/Xpath Function and operators that make sense for RDF nowadays).
>
> XSD date, time and duration formats are the same as RFC 5545, that is
> based on ISO 8601.
>
> SELECT *
> WHERE {
>     BIND( xsd:dateTime("2014-12-09T12:37:40Z") + xsd:duration("PT30M") AS
> ?result)
> }
>
> The casts xsd:dateTime and xsd:duration is only necessary if your input
> data has the dateTime or duration as a string.  If it is already
> ^^xsd:dateTime and ^^xsd:duration, the cast isn't needed.
>
>     Andy
>
>
>
> On Thursday, 23 February 2017 00:01:54 UTC, Steve Ray wrote:
>>
>> Hi,
>>
>>             I’m building a set of SPIN rules, and will need to be able to
>> do calculations on date/time values represented according to RFC 5545, such
>> as:
>>
>>
>>
>> 2014-12-09T12:37:40Z
>>
>>
>>
>> I need to add a duration to such a date/time, again using the same
>> standard, such as:
>>
>>
>>
>> PT30M
>>
>>
>>
>> I dread the idea of parsing these strings, accounting for days in a
>> month, not to mention leap years. It would be amazing if there was a SPIN
>> function library for these operations. Next best I suppose, is a Java
>> library, although I don’t have any experience in calling external Java
>> routines from within a SPIN rule (but I believe it’s not hard, right?).
>>
>>
>>
>> Does anybody have a suggestion of how I might proceed?
>>
>>
>>
>> - Steve
>>
>>
>>
>> Steven R. Ray, Ph.D.
>>
>> Distinguished Research Fellow
>>
>> Carnegie Mellon University
>>
>> NASA Research Park
>>
>>

-- 
You received this message because you are subscribed to the Google Group 
"TopBraid Suite Users", the topics of which include the TopBraid Suite family 
of products and its base technologies such as SPARQLMotion, SPARQL Web Pages 
and SPIN.
To post to this group, send email to [email protected]
--- 
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to