This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 3369 - [F+O] Operations on xs:duration
Summary: [F+O] Operations on xs:duration
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 1.0 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Ashok Malhotra
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
Depends on:
Reported: 2006-06-19 19:10 UTC by Michael Kay
Modified: 2007-02-25 23:30 UTC (History)
0 users

See Also:


Description Michael Kay 2006-06-19 19:10:46 UTC
Section 10.1 of F+O wrongly states:

"Note that only equality is defined on xs:duration values."

This is no longer true: for example, we define casting operations and component extraction on durations. It might be better to say "Note that no ordering relation is defined on xs:duration values. Two xs:duration values may however be compared for equality."

The spec doesn't seem to say how component extraction on durations works. For example, given a duration of 90S, what does seconds-from-duration() return? Test case fn-seconds-from-duration-20 assumes 30.0, which is reasonable, but I can't find anything to back this up, and it runs contrary to the statement in XML Schema that a duration is a 6-tuple. I suggest we add a statement that days|hours|minutes|seconds-from-duration($d) returns the same as days|hours|minutes|seconds-from-duration(xs:dayTimeDuration($d)), and year|month-from-duration($d) returns the same as year|month-from-duration(xs:yearMonthDuration($d))
Comment 1 Ashok Malhotra 2006-06-19 21:07:37 UTC
This section got overlooked when we added additional functions on xs:duration.
Mike suggests a reasonambe solution.
Comment 2 Michael Kay 2006-07-02 04:10:33 UTC
This was discussed at the F2F meeting in Saclay. We agreed that component extraction functions on xs:duration should return the normalized duration. I was actioned to post specific test for the editor to apply.

(a) In Section 10.1, replace "Note that only equality is defined on xs:duration values." by "Note that no ordering relation is defined on xs:duration values. Two xs:duration values may however be compared for equality. Operations on durations (including equality comparison, casting to string, and extraction of components) all treat the duration as normalized: for example, a duration of 120 seconds always gives the same result as a duration of two minutes.

(b) In 10.5, add at the end of the introductory paragraph ("The duration, date and time datatypes may be considered ... For the date/time datatypes the local value is used.") the sentence: "For xs:duration and its subtypes, including the two subtypes xs:yearMonthDuration and xs:dayTimeDuration, the components are normalized: this means that the seconds and minutes components will always be less than 60, the hours component less than 24, and the months component less than 12.

(c) In the description of the individual component extraction functions such as years-from-duration, delete the reference to the canonical lexical representation (because XML Schema does not define such a representation). Instead say (for fn:years-from-duration): 

Summary: Returns an xs:integer representing the years component in the value of $arg. 

The result is given by casting $arg to an xs:yearMonthDuration (see 17.1.4) and then computing the years component as described in

The result may be negative.

If $arg is an xs:dayTimeDuration, returns 0.

If $arg is the empty sequence, returns the empty sequence.

For the other five component extraction the text is the same, mutatis mutandis.
Comment 3 Ashok Malhotra 2006-07-06 13:50:22 UTC
Fixed as agreed to by the WGs in Saclay.
Comment 4 Jim Melton 2007-02-25 23:30:58 UTC
Closing bug because commenter has not objected to the resolution posted and more than two weeks have passed.