GNOME Bugzilla – Bug 452876
week-in-year does not return ISO8601 week numbers
Last modified: 2007-10-10 14:36:47 UTC
I've created a patch to fix week-in-year, added some test cases and also changed some existing test cases because they were expecting incorrect week numbers.
Created attachment 90975 [details] [review] Corrects week-of-year to return ISO6801 week numbers Patch against latest SVN.
I don't see how this is actually a progress: without the patch applied the exslt/date/date.1 test shows Test Date : 0001-12-31Z year : 1 leap-year : false month-in-year : 12 month-name : December month-abbreviation : Dec week-in-year : 53 day-in-year : 365 day-in-month : 31 which looks correct for a 31 December with the patch the same test shows: Test Date : 0001-12-31Z year : 1 leap-year : false month-in-year : 12 month-name : December month-abbreviation : Dec week-in-year : 1 day-in-year : 365 day-in-month : 31 How can that be the first week of the year ? To me this makes no sense and the patch introduce a strong regression, something which worked looks not working anymore. I think you would have to explain the changes to the regression tests data instead of just stating they are incorrect. I don't see how the definition of exslt:date can lead to such a result: http://www.exslt.org/date/functions/week-in-year/index.html As-is the patch looks broken to me, but I may be convinced if you have data to back this out:
I incorrectly referred to ISO 6801, which should have been ISO 8601. Doh! But to give some references to where I got this information: http://en.wikipedia.org/wiki/Week#Week_number http://en.wikipedia.org/wiki/ISO_8601#Week_dates Taken from the ISO 8601:2004(E) pdf that was referenced in the latter: "2.2.10 calendar week number ordinal number which identifies a calendar week within its calendar year according to the rule that the first calendar week of a year is that one which includes the first Thursday of that year and that the last calendar week of a calendar year is the week immediately preceding the first calendar week of the next calendar year." The definition of exslt:date states: "week 1 in a year is the week containing the first Thursday of the year, with new weeks beginning on a Monday." If January 1 is a Thursday, that week will be week 1 and December 31 will be in it.
Okay with all informations in place, yes this looks like a genuine bug, it was not conforming to the eXSLT definition, so patch applied and commited to SVN head, thanks a lot for the report and the patch ! Daniel