isValidDay static method

bool isValidDay(
  1. int year,
  2. int month,
  3. int day
)

Validates if a day is valid for a given month and year

Handles leap years correctly

Returns true if the day is valid, false otherwise

Implementation

static bool isValidDay(int year, int month, int day) {
  if (!isValidYear(year) || !isValidMonth(month)) {
    return false;
  }

  final daysInMonth = DateCalculations.getDaysInMonth(year, month);
  return day >= 1 && day <= daysInMonth;
}