Thomas Broyer said: > Hi there, > > It's been a long time since I last worked on LibXML/LibXSLT/LibEXSLT, > many people here might not know about me⦠I am the man who drafted the > extension framework and committed libexslt, something like 4 or 5 years ago⦠> > Today, I had to add week numbers to a DHTML "datepicker" (screenshot > attached for curious ones) so I went on Gnome CVS to borrow my own > "week-in-year" code. It actually happens it's buggy, and it seems nobody > reported it. > > Sorry not to post into Bugzilla nor patch into CVS directly but I don't > remember my password nor the email address I used at that time⦠> > When computing the week number, it always consider the year to begin on > Monday, while it should use the "day in week" of January 1st. The fix is > simple; instead of the following lines: > > fdiw = (_exsltDateDayInWeek(fdiy, dt->value.date.year) + 6) % 7; > > ret = DAY_IN_YEAR(dt->value.date.day, dt->value.date.mon, > dt->value.date.year) / 7; > > Put these ones: > > fdiw = (_exsltDateDayInWeek(fdiy, dt->value.date.year) + 6) % 7; > > ret = (DAY_IN_YEAR(dt->value.date.day, dt->value.date.mon, > dt->value.date.year) + fdiw) / 7; > > The only change is to adjust the DAY_IN_YEAR result by the "January 1st > day-in-week" value before dividing by 7. That way, week numbers turn on > the appropriate day (in 2005, January 9th is on week 1 while January > 10th is on week 2; whereas without the fix, week 1 would have run from > 1st through 6th and week 2 from 7th to 13th).
OK, thanks - I have applied this fix to CVS. It caused two test results (date.1 and datetime.1) to change, so I also updated those two test result files. Perhaps if you have a moment you might check whether you agree the changed result is, in fact, the correct one. Bill _______________________________________________ xslt mailing list, project page http://xmlsoft.org/XSLT/ [email protected] http://mail.gnome.org/mailman/listinfo/xslt
