[Bug 29555] [FO31] 9.8.4.2 The Width Modifier

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

--- Comment #15 from Michael Kay <mike@saxonica.com> ---
Here is a revised proposal that attempts to take into account comments on the
previous effort.

ACTION A-641-02 (bug 29555) MK to propose a precise algorithm for computing min
and max width of a format-date component; also define an error when min>max.

ACTION A-643-01: MikeK to update proposal on Bug 29555.  

The rules are defined separately for different kinds of component.

(A) For ordinary integer-valued components (specifically, one of MDdFWwHhms)

(A.1) If the first presentation modifier takes the form of a decimal digit
pattern:

A.1.1. If there is no width modifier, then the value is formatted according to
the rules of the format-integer function.

A.1.2. If there is a width modifier, then the first presentation modifier is
adjusted as follows:

A.1.2.a If the decimal digit pattern includes a grouping separator, the output
is implementation-defined (but this is not an error). [Note: use of a width
modifier together with grouping separators is inadvisable for this reason. It
is never necessary to use a width modifier with a decimal digit pattern, since
the same effect can be achieved by use of optional digit signs]

A.1.2.b Otherwise, the number of mandatory-digit-sign characters in the
presentation modifier is increased if necessary. This is done first by
replacing optional-digit-signs with mandatory-digit-signs, starting from the
right, and then prepending mandatory-digit-signs to the presentation modifier,
until the number of mandatory-digit-signs is equal to the minimum width. Any
mandatory-digit-signs that are added by this process must use the same decimal
digit family as existing mandatory-digit-signs in the presentation modifier if
there are any, or ASCII digits otherwise.

A.1.2.c The maximum width, if specified, is ignored.

A.1.2.d The output is then as defined using the format-integer function with
this adjusted decimal digit pattern.

(A.2) If the first presentation modifiers is one of N, n, or Nn:

Let FN be the full name of the component, that is, the form of the name that
would be used in the absence of any width modifier.

If FN is shorter than the minimum width, then it is padded by appending spaces
to the end of the name.

If FN is longer than the maximum width, then it is abbreviated, either by
choosing a conventional abbreviation that fits within the maximum width (for
example, "Wednesday" might be abbreviated to "Weds"), or by removing characters
from the end of F until it fits within the maximum width.

(A.3) For other presentation modifiers: Any adjustment of the value to fit
within the requested width range is implementation-defined. The value should
not be truncated if this results in output that will not be meaningful to users
(for example, there is no sensible way to truncate Roman numerals). If shorter
than the minimum width, the value should be padded to the minimum width, either
by appending spaces, or in some other way appropriate to the numbering scheme.

(B) The rules for the Year component (Y) are the same as those in (A) above,
except that the value of the year as output is the value of the year component
of the supplied value modulo ten to the power N where N is determined as
follows:

(i) if the width modifier is present and includes a maximum width, then that
maximum width, or 2, whichever is greater.

(ii) otherwise, if the first presentation modifier takes the form of a
decimal-digit-pattern, then the number of optional-digit-signs and
mandatory-digit-signs in that decimal-digit-pattern, or 2, whichever is greater

For example: given the year 2016, [Y0001] produces "2016"; [Y01] produces "16";
[Y1] produces "2016"; [Y1,2-2] produces "16"; [Yi] produces "mmxvi"; [Yi,2-2]
produces "xvi".

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

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

C.2 Otherwise, the value of the fractional seconds is output as follows: 

C.2.1. the sequence of characters in the first presentation modifier is
reversed (For example, "999'###" becomes "###'999"). If the result is not a
valid decimal digit pattern, then the output is implementation-defined.

C.2.2. the sequence of digits in the conventional decimal representation of the
fractional seconds component is reversed, with insignicant zeroes removed, and
the result is treated as an integer. For example, if the seconds value is
25.8235, the reversed fractional seconds value is 5328.

C.2.3. The reversed fractional seconds value is formatted using the the
reversed decimal digit pattern according to the rules in (A) above, taking into
account any width modifiers. Given the examples above, the result is "5'328"

C.2.4. The resulting string is reversed. In our example, the result is "823'5".



Finally: we add a rule that if there is a width modifier that specifies both a
minumum and maximum width, then FOFD1340 is reported if the minimum is greater
than the maximum.

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

Received on Friday, 17 June 2016 16:40:14 UTC