Total weeks per month



  • How do we determine the total number (complete + full) of weeks in an arbitrary month? We're starting a week from Monday to Sunday. In other words, how many times the calendar takes a month.

    Ноя.2015 - 6 недель (01.11 - Вс, 30.11 - Пн)
    Дек.2015 - 5 недель (01.12 - Вт, 31.12 - Чт)
    


  • On the basis of the last week of the month, a number of days have been found before Last Monday. This number is seven and round up, getting a stake in the past weeks. before Last week, add 1.

    function getWeeks(year, month) // Внимание: Месяцы нумеруются с 0, как принято в JS
     {
      var l=new Date(year, month+1, 0);
      return Math.ceil( (l.getDate()- (l.getDay()?l.getDay():7))/7 )+1;
     }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2