getNumberOfWeeks method

int getNumberOfWeeks(
  1. int year,
  2. int month
)

Implementation

int getNumberOfWeeks(int year, int month) {
  DateTime lastDayOfMonth = DateTime(year, month + 1, 0);
  return ((lastDayOfMonth.day + lastDayOfMonth.weekday - 1) / 7)
      .ceil();
}