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 21370 - [w] component specifier in date/time formatting is ill-specified
Summary: [w] component specifier in date/time formatting is ill-specified
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.0 (show other bugs)
Version: Candidate Recommendation
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-22 02:20 UTC by Paul J. Lucas
Modified: 2013-05-21 15:51 UTC (History)
2 users (show)

See Also:


Attachments

Description Paul J. Lucas 2013-03-22 02:20:33 UTC
Section "9.8.4.1 The picture string" of the format date/time functions includes the [w] specifier that means "week in month."  Additionally, the test format-dateTime-011 uses [w] in conjunction with the ISO calendar.

However, the ISO 8601 specification has no notion of "week in month" (it only has the notion of "week in year").

Somewhat related, the C function strftime(3) also has no conversion specification for "week in month."

Hence, [w] has no precise meaning for ISO 8601 or in general.
Comment 1 Michael Kay 2013-03-22 09:49:26 UTC
Yes, I agree it's problematic. In my XSLT 2.0 book I say "ISO 8601 does not define a numbering for weeks within a month. You will have to see what your implementation returns".

The difficulty is that [w] is available in XSLT 2.0, even though underspecified, so removing it has its own problems. We could

(a) attempt a specification of what it means

(b) say that the result is implementation-defined

(c) say that it's implementation-defined whether [w] is supported

(d) withdraw or deprecate it

I'm going to specifically ask for XSL WG discussion of this.
Comment 2 Abel Braaksma 2013-03-28 15:49:04 UTC
On (a), the only specification I can think of, is to follow the same rules for the first week of the year in ISO 8601. However, definitions on "week of the month" varies even greater than the first week of the year definitions.

Here's an interesting thread on the subject that I came across: http://linguistlist.org/issues/12/12-1858.html

On (b): I think this is fair

On (c) that would mean a backward compatibility issue. Don't think we should want to do that.

On (d) personally, I prefer that option, but as with (c), it is a backward compatibility issue if we do so.

I don't see any harm in keeping it around, though a note on its underspecification in ISO 8601 might be a good idea.
Comment 3 Anders Berglund 2013-04-10 13:07:37 UTC
The XSLT WG discussed this at the 2013-03-28 telcon.

A "w" specifier is found in many programming language function
libraries and environments [notably it is included in Java].

The consensus was to keep the "w" specifier and specify the semantics.

Proposed changes to F&O:

- In the last item in the list:

"The language is used to select the appropriate language-dependent forms of:

    names (for example, of months)
    numbers expressed as words or as ordinals (twenty, 20th, twentieth)
    hour convention (0-23 vs 1-24, 0-11 vs 1-12)
    first day of week, first week of year"

add "first week of the month".

- After the paragraph following the list (starting "Where appropriate...")
add a paragraph:

"ISO 8601 includes a definition of the first day of the week and first
week of the year, but does not define the first week of the month.
For this recommendation the ISO 8601 definitions are augmented by
a specification that each week begins on a Monday and is associated with
the month that contains that week's Thursday."

- In addition it seems to make sense to move the reference to
ISO 8601 from non-normative to normative.
Comment 4 Paul J. Lucas 2013-04-11 05:02:05 UTC
And what does [w] mean for non-ISO calendars?  For example, the "AD" calendar?  You ought to define what [w] means at least for the "AD" calendar since that's the most common other calendar.
Comment 5 Anders Berglund 2013-04-11 14:57:43 UTC
The definition of the week varies and such local variations are
handled based on language and place. For example the first day
of week (using the "AD" calendar) is commonly either Sunday or
Monday and we cannot mandate either to be used.

Only the ISO "calendar" is precicesly defined and includes a
definitionb of "W" - week in year. Thus it is appropriate for F&O
to include a definition of "w" for use with the ISO calendar
specification.

For other calendars - including the AD one - the result is
implementation defined and should be based on the conventions
based on language and place.
Comment 6 Michael Kay 2013-04-23 11:32:39 UTC
I was asked to draft text to implement the suggstion by Anders in comment 5. The following text is proposed:

ISO 8601 does not define a numbering for weeks within a month. When the <code>w</code>
               component is used, the convention to be adopted is that each Monday-to-Sunday week is considered to
               fall within a particular month if its Thursday occurs in that month; the weeks that fall in a particular
               month under this definition are numbered starting from 1. Thus, for example, 
               29 January 2013 falls in week 5 because the Thursday of the relevant week (31 January 2013) is the fifth Thursday
               in January, and 1 February 2013 is also in week 5 for the same reason.
Comment 7 Michael Kay 2013-05-21 15:51:24 UTC
The text has been agreed (and is present in the new CR published today).