addOrRemoveYears method
Adds or removes the specified number of years from this DateTime.
Implementation
DateTime addOrRemoveYears(int years) {
final newYear = year + years;
final newMonth = month;
var newDay = day;
// Adjust the day if it exceeds the number of days in the new month
while (newDay > DateTime(newYear, newMonth + 1, 0).day) {
newDay--;
}
return DateTime(newYear, newMonth, newDay, hour, minute, second);
}