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 29789 - format-time-023u incorrect result
Summary: format-time-023u incorrect result
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3 & XPath 3 Test Suite (show other bugs)
Version: Candidate Recommendation
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: O'Neil Delpratt
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-23 17:44 UTC by Josh Spiegel
Modified: 2016-12-05 16:11 UTC (History)
2 users (show)

See Also:


Attachments

Description Josh Spiegel 2016-08-23 17:44:56 UTC
<test-case name="format-time-023u" covers="format-ms" xmlns="http://www.w3.org/2010/09/qt-fots-catalog">
      <description>test format-time(): effect of width specifiers </description>
      <created by="Debbie Lockett, Saxonica" on="2016-03-24"/>
      <modified by="Michael Kay, Saxonica" on="2016-07-26" change="bug 29749 changes from rounding to truncation"/>
      <environment>
         <param name="t" as="xs:time" select="xs:time(&apos;09:15:06.006&apos;)"/>
      </environment>
      <dependency type="spec" value="XP31+ XQ31+"/>
      <test><![CDATA[format-time($t, '[f,*-2]')]]></test>
      <result>
         <assert-string-value>0</assert-string-value>
      </result>
</test-case>

FNO, 9.8.4.5, (g):

"If the result contains more digits than the number of mandatory-digit-signs and optional-digit-signs in the decimal digit pattern, then excess digits are removed from the right hand end, and the digits that remain are adjusted if necessary according to the rules of the fn:round-half-to-even function. Any grouping separator that immediately precedes a removed digit is also removed."

Given this text, I would expect this test to return 00 instead of 0. (assuming truncation instead of rounding).  I suppose it may be taken care of depending on how 29749 is applied - raising the bug to track the issue.
Comment 1 Josh Spiegel 2016-09-26 16:02:12 UTC
I was asked to review if this bug is still valid.  It is.

https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-31/html/Overview-diff.html
9.8.4.5 Formatting Fractional Seconds
b.ii. produces "1#"
c. produces "#1"
d. produces 600
e. format-integer(600, "#1") ==> 600
f. 006
g. 00
Comment 2 Michael Kay 2016-11-16 14:50:53 UTC
I was asked to review this (action A-659-04). My interpretation is as follows:

(a) There is no explicit presentation modifier, so the default kicks in, which is "1" (ยง9.8.4.1).

(b) In the width modifier, "*" means "there is no explicit minimum". It's not entirely clear what this means. Specifying zero explicitly would be an error. So I think it makes sense to interpret "*" as "1".

Section 9.8.4.5:

9.8.4.5 Formatting Fractional Seconds

The output for the fractional seconds component (f) is equivalent to the result of the following algorithm:

(1) If the first presentation modifier contains no Unicode digit, then the output is implementation-defined.

We've defaulted the presentation modifier to "1" so it does contain a Unicode digit.

(2) Otherwise, the value of the fractional seconds is output as follows:

(2a) If there is no width modifier and ... N/A

(2b) If there is a width modifier, then the first presentation modifier is adjusted as follows:
The number of mandatory-digit-sign characters in the first presentation modifier is increased if necessary. This is done first by replacing optional-digit-signs with mandatory-digit-signs, starting from the left, and then appending mandatory-digit-signs to the presentation modifier, until the number of mandatory-digit-signs is equal to the minimum width. 

See above, "there is no explicit minimum". So it's not at all clear what happens here. My vote would be to treat "*" as implying minimum width 1, which means that the first presentation modifier remains "1". In comment #1, Josh appears to have decided that the minimum width is 2; I can't see the rationale for that.

(2c) "1" reversed is "1"

(2d) => 600

(2e) => "600"

(2f) => "006"

(2g) => "0"

which is the expected result.

This hinges on an interpretation that "*" as the minimum width in a width specifier means "1", which is the lowest legal value. I can't see any logic for treating it as meaning "2".

I would suggest resolving this ambiguity by prepending to 9.8.4.5 2.b.i the phrase "If a minimum width is specified, ". This change has the same effect as treating the minimum width as 1. The expected test result is then correct.
Comment 3 Andrew Coleman 2016-12-02 10:12:37 UTC
At the meeting on 2016-11-29, the WG agreed with the analysis in comment #2 and to make the proposed wording change in 9.8.4.5 2.b.i.

Action A-662-03 was raised to track this.
Comment 4 Michael Kay 2016-12-05 16:11:25 UTC
The change has been applied.