compareTo method

  1. @override
int compareTo(
  1. Jalali other
)
override

Compare dates

throws on null argument

non-null

Implementation

@override
int compareTo(Jalali other) {
  ArgumentError.checkNotNull(other, 'other');

  if (year != other.year) {
    return year > other.year ? 1 : -1;
  }

  if (month != other.month) {
    return month > other.month ? 1 : -1;
  }

  if (day != other.day) {
    return day > other.day ? 1 : -1;
  }

  if (hour != other.hour) {
    return hour > other.hour ? 1 : -1;
  }

  if (minute != other.minute) {
    return minute > other.minute ? 1 : -1;
  }

  if (second != other.second) {
    return second > other.second ? 1 : -1;
  }

  return 0;
}