<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>1318</bug_id>
          
          <creation_ts>2005-05-10 10:49:52 +0000</creation_ts>
          <short_desc>Comparing durations for equality</short_desc>
          <delta_ts>2005-09-29 10:48:14 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Functions and Operators 1.0</component>
          <version>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Ashok Malhotra">ashok.malhotra</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3565</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2005-05-10 10:49:52 +0000</bug_when>
    <thetext>ACTION: A-252-01 - Michael Kay will file a separate LC comment on &quot;Specify an
equality comparison for xs:duration values&quot; and proposing a comparison
mechanism.  Bug 1208 should be dependent on the new bug, and when we resolve the
new bug we will revisit 1208.

We should define an equality comparison for xs:duration values.

(a) There&apos;s no good reason not to. Although ordering of durations is
problematical, there&apos;s no problem defining equality. Admittedly there is more
than one possible definition, but that&apos;s true of many of our data types.

(b) Not having an equality operation for durations causes implementation
difficulties with other operations such as distinct-values(), deep-equal(), and
(in XSLT) sorting and grouping. For example, distinct-values() treats all
durations as distinct from each other, which makes it hard to come up with a
suitable hashing function; similarly, deep-equal() has to search a document to
arbitrary depth, because if it contains a duration anywhere then it is not
deep-equal to any other document, not even itself.

The proposed definition is that two durations $d1 and $d2 are equal if and only
if xdt:dayTimeDuration($d1) eq xdt:dayTimeDuration($d2) and
xdt:yearMonthDuration($d1) eq xdt:yearMonthDuration($d2).

To implement this:

(a) in the language books, add two lines to the operator mapping table in B.2:

A eq B | xs:duration | xs:duration | op:duration-equal(A, B) | xs:boolean
A ne B | xs:duration | xs:duration | fn:not(op:duration-equal(A, B)) | xs:boolean

(b) Add a new function to F+O:

10.4.x op:duration-equal

op:duration-equal( $arg1 as xs:duration,
                   $arg2 as xs:duration) as xs:boolean

Summary: Returns true if and only if $arg1 is equal to $arg2. Returns false
otherwise.

This function backs up the &quot;eq&quot; and &quot;ne&quot; operators on xs:duration values.

The function returns true if xdt:dayTimeDuration($arg1) eq
xdt:dayTimeDuration($arg2) and xdt:yearMonthDuration($arg1) eq
xdt:yearMonthDuration($arg2); otherwise it return false.

Examples:

xs:duration(&quot;P1Y&quot;) eq xs:duration(&quot;P12M&quot;) returns true.
xs:duration(&quot;PT24H&quot;) eq xs:duration(&quot;P1D&quot;) returns true.
xs:duration(&quot;P1Y&quot;) eq xs:duration(&quot;P365D&quot;) returns false. 


Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3418</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2005-05-10 10:55:51 +0000</bug_when>
    <thetext>In F+O, Appendix D.6 should also be removed, as should the paragraph in 10.2 &quot;No
operators are defined on the [XML Schema Part 2: Datatypes Second Edition]
datatype xs:duration. Appendix D.6 Working With xs:duration Values discusses how
to work with xs:duration values.&quot;. 

In 10.4, change &quot;For this reason, no functions are defined on xs:duration.&quot; to
&quot;For this reason, no ordering functions are defined on xs:duration.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2989</commentid>
    <comment_count>2</comment_count>
    <who name="Ashok Malhotra">ashok.malhotra</who>
    <bug_when>2005-05-31 16:34:46 +0000</bug_when>
    <thetext>The joint WGs agreed to add the operator op:duration-equal and make the changes
suggested by Michael Kay in the comments attached to this note to the F&amp;O and
the language book.  See minutes on joint WG meeting 5-16-2005.

Ashok Malhotra</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>