daysLeftInYear method

int daysLeftInYear(
  1. int monthNum,
  2. int dayNum,
  3. int year
)

It returns the number of days left in the year.

Args: monthNum (int): The number of the month (1-12) dayNum (int): The day of the month (1-31) year (int): The year in question.

Implementation

int daysLeftInYear(final int monthNum, final int dayNum, final int year) {
  var totalMonthLength = 0;
  for (var count = 1; count < monthNum; count++) {
    totalMonthLength += daysInMonth(count, year)!;
  }
  return totalMonthLength + dayNum - daysInYear(year);
}