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 29515 - The expected result of format-dateTime-011 is incorrect
Summary: The expected result of format-dateTime-011 is incorrect
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:
: 29493 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-03-02 18:21 UTC by Josh Spiegel
Modified: 2016-03-08 18:03 UTC (History)
1 user (show)

See Also:


Attachments

Description Josh Spiegel 2016-03-02 18:21:54 UTC
See:
https://github.com/LeoWoerteler/QT3TS/blob/17419434879ee1eeeb6fc1be81e1df063e363a17/fn/format-dateTime.xml#L533

For a sequence of months, this test prints out the [w] value for the first day of each month.  If the first day of the month falls in the first week of the month, the test expects [w]==1 (which is correct).  However, if the first day is not in the first week of the month, it always expects [w]==5 (which is only sometimes correct).  The problem is that sometimes the first day of the month falls in week 4 (not 5) of the previous month.  For example, consider:

   [2008-03-01T12:00:00: 5

The calendar for February/March 2008:

 February 2008
   S  M  T  W  T  F  S
                  1  2
   3  4  5  6  7  8  9
   10 11 12 13 14 15 16
   17 18 19 20 21 22 23
   24 25 26 27 28 29  

 March 2008
   S  M  T  W  T  F  S
                     1
   2  3  4  5  6  7  8
   ...   
   
March 1st is not in the first week of march.  It is in the 4th week of February.  However, the test expects it in the 5th week of February. 

Here is the relevant part of the spec:
https://www.w3.org/TR/xpath-functions-31/#rules-for-datetime-formatting
<quote>
ISO 8601 does not define a numbering for weeks within a month. When the w 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 week (31 January 2013) is the fifth Thursday in January, and 1 February 2013 is also in week 5 for the same reason.
</quote>


History
------------
This bug is relevant:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21794

Comment 0 suggests:
"Every expected week number of "0" should be a "5", i.e., the 5th week of the previous month."

Which was applied here:
https://github.com/LeoWoerteler/QT3TS/commit/c105cefb05d2d334ed04da0888614635ac7f492b#diff-e0aeb5496b2546ae68a1e5827d02e6df

Here are a list of dates covered by this test where I think 5 should instead be 4:
 
  2006-10-01T12:00:00
  2007-07-01T12:00:00
  2008-03-01T12:00:00
  2009-03-01T12:00:00
Comment 1 O'Neil Delpratt 2016-03-08 18:01:24 UTC
*** Bug 29493 has been marked as a duplicate of this bug. ***
Comment 2 Josh Spiegel 2016-03-08 18:03:02 UTC
The working group accepted the modification proposed in comment 0.