isAtSameMomentAs method

  1. @override
bool isAtSameMomentAs(
  1. covariant NepaliDateTime other
)
override

Returns true if this occurs at the same moment as other.

The comparison is independent of whether the time is in UTC or in the local time zone.

final now = DateTime.now();
final later = now.add(const Duration(seconds: 5));
print(!later.isAtSameMomentAs(now)); // true
print(now.isAtSameMomentAs(now)); // true

// This relation stays the same, even when changing timezones.
print(!later.isAtSameMomentAs(now.toUtc())); // true
print(!later.toUtc().isAtSameMomentAs(now)); // true

print(now.toUtc().isAtSameMomentAs(now)); // true
print(now.isAtSameMomentAs(now.toUtc())); // true

Implementation

@override
bool isAtSameMomentAs(covariant NepaliDateTime other) {
  return millisecondsSinceEpoch == other.millisecondsSinceEpoch;
}