yearsDiff method
Implementation
int yearsDiff(DateTime other) {
DateTime earlierDate = isBefore(other) ? this : other;
DateTime laterDate = isBefore(other) ? other : this;
int yearDiff = laterDate.year - earlierDate.year;
if (laterDate.month < earlierDate.month || (laterDate.month == earlierDate.month && laterDate.day < earlierDate.day)) {
yearDiff--;
}
return yearDiff;
}