calculateDayRange static method

List<int> calculateDayRange({
  1. required DateTime minDateTime,
  2. required DateTime maxDateTime,
  3. required int? currentYear,
  4. required int? currentMonth,
})

Implementation

static List<int> calculateDayRange(
  {
    required DateTime minDateTime,
    required DateTime maxDateTime,
    required int? currentYear,
    required int? currentMonth,
  }
) {
  int minDay = 1, maxDay = _calculateDayCountOfMonth(currentMonth, currentYear);
  int minYear = minDateTime.year;
  int maxYear = maxDateTime.year;
  int minMonth = minDateTime.month;
  int maxMonth = maxDateTime.month;

  if (minYear == currentYear && minMonth == currentMonth) {
    minDay = minDateTime.day;
  }
  if (maxYear == currentYear && maxMonth == currentMonth) {
    maxDay = maxDateTime.day;
  }
  return [minDay, maxDay];
}