compareDatesAtResolution function

int compareDatesAtResolution(
  1. Date a,
  2. Date? b,
  3. CalendarResolution resolution
)

Implementation

int compareDatesAtResolution(Date a, Date? b, CalendarResolution resolution) {
  switch (resolution) {
    case CalendarResolution.years:
      return a.year.compareTo(b!.year);
    case CalendarResolution.months:
      if (a.year == b!.year) return a.month.compareTo(b.month);
      return a.year.compareTo(b.year);
    case CalendarResolution.days:
      return a.compareTo(b);
    case CalendarResolution.weeks:
    default:
      throw ArgumentError(
          'Comparison not supported at resolution: $resolution');
  }
}