function getWeeksInMonth(
  month,
  year = new Date().getFullYear(),
  weekStartsOn,
  isLastDisplayedMonth
) {
  const weekEndsOn = getEndOfWeekIndex(weekStartsOn);

  const firstOfMonth = new Date(year, month, 1);
  const firstWeekNumber = getWeek(year, firstOfMonth, weekStartsOn);

  const lastOfMonth = new Date(year, month + 1, 0); // Last date of the Month
  const lastWeekNumber = getWeek(year, lastOfMonth, weekStartsOn);

  let rowCount = lastWeekNumber - firstWeekNumber;

  // If the last week contains 7 days, we need to add an extra row
  if (lastOfMonth.getDay() === weekEndsOn || isLastDisplayedMonth) {
    rowCount++;
  }

  return rowCount;
}
Get the number of weeks in a given month to be able to calculate the height of that month
@param {Number} year - the year number
@param {Number} month - the index of the month
@param {Number} weekStartsOn - the index of the first day of the week (from 0 to 6)
@return {Number} - Returns the number of weeks for the given month