getSignedMonthDifference static method

int getSignedMonthDifference({
  1. required DateTime startDate,
  2. required DateTime endDate,
})

Calculates the signed difference in months from startDate to endDate.

Positive if endDate is after startDate, negative if before. Day of month is ignored.

Implementation

static int getSignedMonthDifference({
  required DateTime startDate,
  required DateTime endDate,
}) =>
    (endDate.year - startDate.year) * 12 + endDate.month - startDate.month;