yearsMonthsDaysToDays static method

int yearsMonthsDaysToDays(
  1. int years,
  2. int months,
  3. int days
)

Implementation

static int yearsMonthsDaysToDays(int years, int months, int days) {
  int totalDays = 0;

  // Convert years to days
  for (int year = 0; year < years; year++) {
    totalDays += isLeapYear(year) ? 366 : 365;
  }

  // Convert months to days
  for (int month = 0; month < months; month++) {
    totalDays += DateTime(DateTime.now().year, month + 2, 0).day;
  }

  // Add the given days to the total
  totalDays += days;

  return totalDays;
}