title: JavaScript Date.getWeek()?
body: <p>I'm looking for a tested solid solution for getting current week of the year for specified date. All I can find are the ones that doesn't take in account leap years or just plain wrong. Does anyone have this type of stuff?</p>
  
  <p>Or even better a function that says how many weeks does month occupy. It is usually 5, but can be 4 (feb) or 6 (1st is sunday and month has 30-31 days in it)</p>
  
  <p>=================
  <strong>UPDATE:</strong></p>
  
  <p>Still not sure about getting week #, but since I figured out it won't solve my problem with calculating how many weeks month occupy, I abandoned it.</p>
  
  <p>Here's a function to find out how many weeks exactly month occupy on the calendar: </p>
  
  <pre><code>getWeeksNum: function(year, month) {
      var daysNum = 32 - new Date(year, month, 32).getDate(),
          fDayO = new Date(year, month, 1).getDay(),
          fDay = fDayO ? (fDayO - 1) : 6,
          weeksNum = Math.ceil((daysNum + fDay) / 7);
      return weeksNum;
  }
  </code></pre>