isAtSameMomentAs method

bool isAtSameMomentAs(
  1. IsoDuration other
)

Returns true if this IsoDuration occurs at the same time as other.

This is different from == (equals), where all properties must be same, not only the total duration.

Each IsoDuration is calculated as a sum of all properties and then the duration is compared.

Example:

final dur = IsoDuration(hours: 0, minutes: 60);
final dur2 = IsoDuration(hours: 1, minutes: 0);
final dur3 = IsoDuration(minutes: 60);
dur.isAtSameMomentAs(dur2); // true
dur == dur2; // false
dur == dur3; // true

Implementation

bool isAtSameMomentAs(IsoDuration other) {
  if (this == other) return true;
  if (isPrecise && other.isPrecise) return toSeconds() == other.toSeconds();
  return _isAtSameMomentAs(other);
}