add method

  1. @override
Jalali add({
  1. int years = 0,
  2. int months = 0,
  3. int days = 0,
  4. int hours = 0,
  5. int minutes = 0,
  6. int seconds = 0,
  7. int milliseconds = 0,
})
override

makes a new date instance and add days, months and years separately

Original date object remains unchanged

Note: It does not make any conversion, it simply adds to each field value and changes ALL at once

This Method is NOT safe for month and day bounds

Recommended: Use separate add*() methods

Implementation

@override
Jalali add({
  int years = 0,
  int months = 0,
  int days = 0,
  int hours = 0,
  int minutes = 0,
  int seconds = 0,
  int milliseconds = 0,
}) {
  if (years == 0 &&
      months == 0 &&
      days == 0 &&
      hours == 0 &&
      minutes == 0 &&
      seconds == 0 &&
      milliseconds == 0) {
    return this;
  } else {
    return Jalali(
      year + years,
      month + months,
      day + days,
      hour + hours,
      minute + minutes,
      second + seconds,
      millisecond + milliseconds,
    );
  }
}