diff method

int diff(
  1. Day day, [
  2. String unit = Unit.ms
])

Returns a number with the difference between two days by specified unit.

Implementation

int diff(Day day, [String unit = Unit.ms]) {
  final difference = _time.difference(day._time);
  final processedUnit = Unit.fromShorthand(unit);

  switch (processedUnit) {
    case Unit.y:
      return (year() - day.year());
    case Unit.m:
      return (year() - day.year()) * 12 + (month() - day.month());
    default:
      return u.processDiffDuration(difference, processedUnit);
  }
}