rem: var weekNumber = Math.floor(thisWeeksThursday/7)+1; 
add:  if (thisWeeksThursday > aDateTime.endOfYear.yearday) thisWeeksThursday -= aDateTime.endOfYear.yearday;  var weekNumber = Math.ceil(thisWeeksThursday/7); 
context: function getWeekTitle(aDateTime) {    /**     * This implementation is based on the ISO 8601 standard.       * ISO 8601 defines week one as the first week with at least 4     * days, and defines Monday as the first day of the week.     * Equivalently, the week one is the week with the first Thursday.     *      * This implementation uses the second definition, because it     * enables the user to set a different start-day of the week     * (Sunday instead of Monday is a common setting).  If the first     * definition was used, all week-numbers could be off by one     * depending on the week start day.  (For example, if weeks start     * on Sunday, a year that starts on Thursday has only 3 days     * [Thu-Sat] in that week, so it would be part of the last week of     * the previous year, but if weeks start on Monday, the year would     * have four days [Thu-Sun] in that week, so it would be counted     * as week 1.)     */    // The week number is the number of days since the start of week    // one, divided by 7, plus 1 (so the first week is W1, not W0).    // Week one is the week containing the first Thursday.    // Thus, the week number of any day is the same as the number of days    // between the thursday of that week and the thursday of week one,    // divided by 7, plus 1.  (This takes care of days at end/start of    // year which may be part of last/first week in other year.)    // The Thursday of a week is the Thursday that follows the first day    // of the week.    //     // The week number of a day is the same as the week number of    // the first day of the week. (This takes care of days near the    // start of the year, which may be part of the week counted in    // the previous year.)  So we need the start weekDay.    const SUNDAY = 0;    var startWeekday = SUNDAY; // default to monday per ISO8601 standard.    try {             var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]                                   .getService(Components.interfaces.nsIPrefBranch);        startWeekDay = prefBranch.getIntPref("calendar.week.start");    } catch (e) {}    // The number of days since the start of the week.    // Notice that the result of the substraction might be negative.    // We correct for that by adding 7, and then using the remainder operator.    var sinceStartOfWeek = (aDateTime.weekday - startWeekday + 7) % 7;     // The number of days to thursday is the difference between Thursday    // and the start day of the week (again corrected for negative values)    const THURSDAY = 4;    var startToThursday = (THURSDAY - startWeekday + 7) % 7;    // The yearday number of the thursday this week    var thisWeeksThursday = aDateTime.yearday - sinceStartOfWeek + startToThursday;    // For the first few days of the year, we might still be in week 52.    if (thisWeeksThursday < 0)        thisWeeksThursday += 52*7;    var weekNumber = Math.floor(thisWeeksThursday/7)+1;    return weekNumber;};
meta: 8395	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/8395/6c8a5823b77d7e3f4dbd8e03ba5d5bb775c16536/calWeekTitleService.js/buggy/calendar/base/src/calWeekTitleService.js