build/ical.js
function weekNumber(aWeekStart) {
      var wnCacheKey = (this.year << 12) + (this.month << 8) + (this.day << 3) + aWeekStart;
      if (wnCacheKey in ICAL.Time._wnCache) {
        return ICAL.Time._wnCache[wnCacheKey];
      }
      // This function courtesty of Julian Bucknall, published under the MIT license
      // http://www.boyet.com/articles/publishedarticles/calculatingtheisoweeknumb.html
      // plus some fixes to be able to use different week starts.
      var week1;

      var dt = this.clone();
      dt.isDate = true;
      var isoyear = this.year;

      if (dt.month == 12 && dt.day > 25) {
        week1 = ICAL.Time.weekOneStarts(isoyear + 1, aWeekStart);
        if (dt.compare(week1) < 0) {
          week1 = ICAL.Time.weekOneStarts(isoyear, aWeekStart);
        } else {
          isoyear++;
        }
      } else {
        week1 = ICAL.Time.weekOneStarts(isoyear, aWeekStart);
        if (dt.compare(week1) < 0) {
          week1 = ICAL.Time.weekOneStarts(--isoyear, aWeekStart);
        }
      }

      var daysBetween = (dt.subtractDate(week1).toSeconds() / 86400);
      var answer = ICAL.helpers.trunc(daysBetween / 7) + 1;
      ICAL.Time._wnCache[wnCacheKey] = answer;
      return answer;
    }
function weekNumber(aWeekStart) {
      var wnCacheKey = (this.year << 12) + (this.month << 8) + (this.day << 3) + aWeekStart;
      if (wnCacheKey in ICAL.Time._wnCache) {
        return ICAL.Time._wnCache[wnCacheKey];
      }
      // This function courtesty of Julian Bucknall, published under the MIT license
      // http://www.boyet.com/articles/publishedarticles/calculatingtheisoweeknumb.html
      // plus some fixes to be able to use different week starts.
      var week1;

      var dt = this.clone();
      dt.isDate = true;
      var isoyear = this.year;

      if (dt.month == 12 && dt.day > 25) {
        week1 = ICAL.Time.weekOneStarts(isoyear + 1, aWeekStart);
        if (dt.compare(week1) < 0) {
          week1 = ICAL.Time.weekOneStarts(isoyear, aWeekStart);
        } else {
          isoyear++;
        }
      } else {
        week1 = ICAL.Time.weekOneStarts(isoyear, aWeekStart);
        if (dt.compare(week1) < 0) {
          week1 = ICAL.Time.weekOneStarts(--isoyear, aWeekStart);
        }
      }

      var daysBetween = (dt.subtractDate(week1).toSeconds() / 86400);
      var answer = ICAL.helpers.trunc(daysBetween / 7) + 1;
      ICAL.Time._wnCache[wnCacheKey] = answer;
      return answer;
    }
function weekNumber ( aWeekStart ) { var wnCacheKey = ( this . year << 12 ) + ( this . month << 8 ) + ( this . day << 3 ) + aWeekStart ; if ( wnCacheKey in ICAL . Time . _wnCache ) { return ICAL . Time . _wnCache [ wnCacheKey ] ; } // This function courtesty of Julian Bucknall, published under the MIT license // http://www.boyet.com/articles/publishedarticles/calculatingtheisoweeknumb.html // plus some fixes to be able to use different week starts. var week1 ; var dt = this . clone ( ) ; dt . isDate = true ; var isoyear = this . year ; if ( dt . month == 12 && dt . day > 25 ) { week1 = ICAL . Time . weekOneStarts ( isoyear + 1 , aWeekStart ) ; if ( dt . compare ( week1 ) < 0 ) { week1 = ICAL . Time . weekOneStarts ( isoyear , aWeekStart ) ; } else { isoyear ++ ; } } else { week1 = ICAL . Time . weekOneStarts ( isoyear , aWeekStart ) ; if ( dt . compare ( week1 ) < 0 ) { week1 = ICAL . Time . weekOneStarts ( -- isoyear , aWeekStart ) ; } } var daysBetween = ( dt . subtractDate ( week1 ) . toSeconds ( ) / 86400 ) ; var answer = ICAL . helpers . trunc ( daysBetween / 7 ) + 1 ; ICAL . Time . _wnCache [ wnCacheKey ] = answer ; return answer ; }
Calculates the ISO 8601 week number. The first week of a year is the
week that contains the first Thursday. The year can have 53 weeks, if
January 1st is a Friday.

Note there are regions where the first week of the year is the one that
starts on January 1st, which may offset the week number. Also, if a
different week start is specified, this will also affect the week
number.

@see ICAL.Time.weekOneStarts
@param {ICAL.Time.weekDay} aWeekStart        The weekday the week starts with
@return {Number}                             The ISO week number
Calculates the ISO 8601 week number . The first week of a year is the week that contains the first Thursday . The year can have 53 weeks if January 1st is a Friday .