W3C home > Mailing lists > Public > public-qt-comments@w3.org > August 2019

[FO31errata] A problem in the definition of the op:subtract-dateTimes function

From: Boris Motik <boris.motik@cs.ox.ac.uk>
Date: Tue, 6 Aug 2019 15:42:05 +0000
To: "public-qt-comments@w3.org" <public-qt-comments@w3.org>
Message-ID: <CDE4BAD2-8274-4E6C-81A6-F17FBA082B89@cs.ox.ac.uk>
Hello,

Section 9.7.2 (https://www.w3.org/TR/xpath-functions-3/#func-subtract-dateTimes) of the XPath and XQuery Functions and Operators 3.1 document defines the op:subtract-dateTimes function as follows:

The function returns the elapsed time between the date/time instant arg2 and the date/time instant arg1, computed according to the algorithm given in Appendix E of [XML Schema Part 2: Datatypes Second Edition], and expressed as a xs:dayTimeDuration.

Unfortunately, the XML Schema Datatypes specification does not seem to contain such an algorithm: both https://www.w3.org/TR/xmlschema-2/ and https://www.w3.org/TR/xmlschema11-2/ contain only an algorithm for adding xs:duration to an xs:dateTime, but neither of them contains an algorithm for subtracting xs:dateTime objects. In fact, the latter document says the following:

 duration can provide addition and subtraction operations between duration values and between duration/dateTime value pairs, and can be the result of subtracting dateTime values.

Hence, this seems to me like an omission in the standard.


I thought a bit about this issue and came to the conclusion that the resolution is nontrivial as there seem to be at least two possible ways of computing the difference.

1. Two xs:dateTime objects represent fixed points in time, so one can compute the elapsed number of seconds between them. Thus, the difference could be represented as an xs:duration object whose month component is zero and the second component is the time difference.

2. One could compute both the number of elapsed months and the number of elapsed seconds and construct an xs:duration object in that way.

The second solution seems applicable to date/time datatypes other than xs:dateTime (such as xs:time or xs:gMonthYear), whereas the first solution seems applicable only to xs:dateTime and xs:dateTimeStamp datatypes.

In any case, clarification on this point would be useful.

Regards,

Boris Motik
Received on Tuesday, 6 August 2019 15:42:32 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:58:06 UTC