lib/academicCalendar.js
function getAcadWeekInfo(date) {
  var currentAcad = getAcadYear(date);
  var acadYear = currentAcad.year;
  var acadYearStartDate = currentAcad.startDate;

  var acadWeekNumber = Math.ceil((date.getTime() - acadYearStartDate.getTime() + 1) / oneWeekDuration);
  var semester = getAcadSem(acadWeekNumber);

  var weekType = null;
  var weekNumber = null;
  switch (semester) {
    case sem2:
      // Semester 2 starts 22 weeks after Week 1 of semester 1
      acadWeekNumber -= 22;
    case sem1:
      if (acadWeekNumber === 1) {
        weekType = 'Orientation';
        break;
      }
      if (acadWeekNumber > 18) {
        weekType = 'Vacation';
        weekNumber = acadWeekNumber - 18;
        break;
      }
      acadWeekNumber -= 1;
      {
        var week = getAcadWeekName(acadWeekNumber);
        weekType = week.weekType;
        weekNumber = week.weekNumber;
      }
      break;
    case special2:
      // Special Term II starts 6 weeks after Special Term I
      acadWeekNumber -= 6;
    case special1:
      // Special Term I starts on week 41 of the AY
      acadWeekNumber -= 40;
      weekType = 'Instructional';
      weekNumber = acadWeekNumber;
      break;
    default:
      if (acadWeekNumber === 53) {
        // This means it is the 53th week of the AY, and this week is Vacation.
        // This happens 5 times every 28 years.
        weekType = 'Vacation';
        weekNumber = null;
      }
      break;
  }

  return {
    year: acadYear,
    sem: semester,
    type: weekType,
    num: weekNumber
  };
}
function getAcadWeekInfo(date) {
  var currentAcad = getAcadYear(date);
  var acadYear = currentAcad.year;
  var acadYearStartDate = currentAcad.startDate;

  var acadWeekNumber = Math.ceil((date.getTime() - acadYearStartDate.getTime() + 1) / oneWeekDuration);
  var semester = getAcadSem(acadWeekNumber);

  var weekType = null;
  var weekNumber = null;
  switch (semester) {
    case sem2:
      // Semester 2 starts 22 weeks after Week 1 of semester 1
      acadWeekNumber -= 22;
    case sem1:
      if (acadWeekNumber === 1) {
        weekType = 'Orientation';
        break;
      }
      if (acadWeekNumber > 18) {
        weekType = 'Vacation';
        weekNumber = acadWeekNumber - 18;
        break;
      }
      acadWeekNumber -= 1;
      {
        var week = getAcadWeekName(acadWeekNumber);
        weekType = week.weekType;
        weekNumber = week.weekNumber;
      }
      break;
    case special2:
      // Special Term II starts 6 weeks after Special Term I
      acadWeekNumber -= 6;
    case special1:
      // Special Term I starts on week 41 of the AY
      acadWeekNumber -= 40;
      weekType = 'Instructional';
      weekNumber = acadWeekNumber;
      break;
    default:
      if (acadWeekNumber === 53) {
        // This means it is the 53th week of the AY, and this week is Vacation.
        // This happens 5 times every 28 years.
        weekType = 'Vacation';
        weekNumber = null;
      }
      break;
  }

  return {
    year: acadYear,
    sem: semester,
    type: weekType,
    num: weekNumber
  };
}
function getAcadWeekInfo ( date ) { var currentAcad = getAcadYear ( date ) ; var acadYear = currentAcad . year ; var acadYearStartDate = currentAcad . startDate ; var acadWeekNumber = Math . ceil ( ( date . getTime ( ) - acadYearStartDate . getTime ( ) + 1 ) / oneWeekDuration ) ; var semester = getAcadSem ( acadWeekNumber ) ; var weekType = null ; var weekNumber = null ; switch ( semester ) { case sem2 : // Semester 2 starts 22 weeks after Week 1 of semester 1 acadWeekNumber -= 22 ; case sem1 : if ( acadWeekNumber === 1 ) { weekType = 'Orientation' ; break ; } if ( acadWeekNumber > 18 ) { weekType = 'Vacation' ; weekNumber = acadWeekNumber - 18 ; break ; } acadWeekNumber -= 1 ; { var week = getAcadWeekName ( acadWeekNumber ) ; weekType = week . weekType ; weekNumber = week . weekNumber ; } break ; case special2 : // Special Term II starts 6 weeks after Special Term I acadWeekNumber -= 6 ; case special1 : // Special Term I starts on week 41 of the AY acadWeekNumber -= 40 ; weekType = 'Instructional' ; weekNumber = acadWeekNumber ; break ; default : if ( acadWeekNumber === 53 ) { // This means it is the 53th week of the AY, and this week is Vacation. // This happens 5 times every 28 years. weekType = 'Vacation' ; weekNumber = null ; } break ; } return { year : acadYear , sem : semester , type : weekType , num : weekNumber } ; }
Computes the current academic week and return in an object of acad date components
@param  {Date} date
@return {Object} {
year: "15/16",
sem: 'Semester 1'|'Semester 2'|'Special Sem 1'|'Special Sem 2',
type: 'Instructional'|'Reading'|'Examination'|'Recess'|'Vacation'|'Orientation',
num: <weekNum>
}
Computes the current academic week and return in an object of acad date components