<?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>30041</bug_id>
          
          <creation_ts>2017-01-04 15:54:27 +0000</creation_ts>
          <short_desc>[FO31] year-from-date() with negative years</short_desc>
          <delta_ts>2017-01-10 17:55:08 +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 3.1</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>editorial</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>andrew_coleman</cc>
          
          <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>128346</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2017-01-04 15:54:27 +0000</bug_when>
    <thetext>I don&apos;t think we have 100% clarity of what the expected result of 

year-from-date(&apos;-0001-06-06&apos;)

should be.

XSD 1.0 says:

&apos;-0001&apos; is the lexical representation of the year 1 Before Common Era (1 BCE, sometimes written &quot;1 BC&quot;).... It is the intention of the XML Schema Working Group to allow &apos;0000&apos; as a lexical representation in the dateTime, date, gYear, and gYearMonth datatypes in a subsequent version of this Recommendation. &apos;0000&apos; will be the lexical representation of 1 BCE (which is a leap year), &apos;-0001&apos; will become the lexical representation of 2 BCE (not 1 BCE as in this (1.0) version), &apos;-0002&apos; of 3 BCE, etc.

and this intention was carried out in XSD 1.1

A reader might therefore assume that the result of year-from-date(&apos;-0001-06-06&apos;)
should be -1 under XSD 1.0 and -2 under XSD 1.1. Indeed, this reader appears to have made this assumption. (Causing test fn-year-from-dateTime-6 to fail in Saxon when XSD 1.1 is enabled).

The F+O spec itself says only &quot;the function returns an xs:integer representing the year component in the local value of $arg. The result may be negative.&quot; The definition of &quot;local value&quot; (if it can be called that) in 9.2 does not really address the question. But in the introduction to 9.5 (which defines year-from-date() and year-from-dateTime()) we have an alternative definition:

In all cases the local value (that is, the original value as written, without any timezone adjustment) is used.

which suggests that the intended result is -1.

Generally I think that returning -1 gives fewest surprises and least risk of breaking anything, so I propose that we should clarify, perhaps by means of annotated examples, that this is the expected result. Test case fn-year-from-dateTime-6 is then correct for both XSD versions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128354</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2017-01-10 17:55:08 +0000</bug_when>
    <thetext>The change was deemed editorial (in that it merely clarifies what the spec already says if you read it carefully enough) and has been applied.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>