difference method

TimeOfDay difference(
  1. TimeOfDay other
)

Returns the difference between this TimeOfDay and the other TimeOfDay as a new TimeOfDay.

Implementation

TimeOfDay difference(TimeOfDay other) {
  final thisMinutes = hour * 60 + minute;
  final otherMinutes = other.hour * 60 + other.minute;

  final diff = thisMinutes - otherMinutes;

  final hours = diff ~/ 60;
  final minutes = diff % 60;

  return TimeOfDay(hour: hours, minute: minutes);
}