compareDatesAtResolution function
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');
}
}