addTo method
Adds this duration to the given input
DateTime.
This is adding this duration precisely and is better than toDuration in most cases.
Implementation
DateTime addTo(DateTime input) {
var y = input.year + years;
var m = input.month + months;
while (m > 12) {
y++;
m -= 12;
}
final intermediate = DateTime(y, m, input.day, input.hour, input.minute,
input.second, input.millisecond, input.microsecond);
final duration = Duration(
days: weeks * 7 + days,
hours: hours,
minutes: minutes,
seconds: seconds,
);
return intermediate.add(duration);
}