[Bug 30041] New: [FO31] year-from-date() with negative years

https://www.w3.org/Bugs/Public/show_bug.cgi?id=30041

            Bug ID: 30041
           Summary: [FO31] year-from-date() with negative years
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Functions and Operators 3.1
          Assignee: mike@saxonica.com
          Reporter: mike@saxonica.com
        QA Contact: public-qt-comments@w3.org
  Target Milestone: ---

I don't think we have 100% clarity of what the expected result of 

year-from-date('-0001-06-06')

should be.

XSD 1.0 says:

'-0001' is the lexical representation of the year 1 Before Common Era (1 BCE,
sometimes written "1 BC").... It is the intention of the XML Schema Working
Group to allow '0000' as a lexical representation in the dateTime, date, gYear,
and gYearMonth datatypes in a subsequent version of this Recommendation. '0000'
will be the lexical representation of 1 BCE (which is a leap year), '-0001'
will become the lexical representation of 2 BCE (not 1 BCE as in this (1.0)
version), '-0002' 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('-0001-06-06')
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 "the function returns an xs:integer representing
the year component in the local value of $arg. The result may be negative." The
definition of "local value" (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.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Wednesday, 4 January 2017 15:54:35 UTC