isSameSecond method

bool isSameSecond(
  1. DateTime other
)

Whether two DateTime fall within the same second.

Compared on the absolute timeline (epoch seconds) so that UTC and local instances representing different instants are never considered equal, regardless of their wall-clock components.

Implementation

bool isSameSecond(DateTime other) =>
    millisecondsSinceEpoch ~/ 1000 == other.millisecondsSinceEpoch ~/ 1000;