addMonths method
add months
to this date
this Method is safe for month and year bounds
throws DateException on month length or leap crash
throws on null argument
non-null
Implementation
@override
Jalali addMonths(int months) {
ArgumentError.checkNotNull(months, 'months');
if (months == 0) {
return this;
} else {
// this is fast enough, no need for further optimization
final int sum = month + months - 1;
final int mod = sum % 12;
// can not use "sum ~/ 12" directly
final int deltaYear = (sum - mod) ~/ 12;
return Jalali(year + deltaYear, mod + 1, day);
}
}