operator == method

  1. @override
bool operator ==(
  1. Object other
)
override

Checks equality with another object.

Two ZonedDateTime objects are equal if they represent the same instant in time, regardless of their timezone.

Example:

final dt1 = ZonedDateTime.parse('2023-12-25T12:00:00-05:00[America/New_York]');
final dt2 = ZonedDateTime.parse('2023-12-25T17:00:00+00:00[UTC]');

print(dt1 == dt2); // true (same instant)

Implementation

@override
bool operator ==(Object other) {
  if (identical(this, other)) return true;
  return other is ZonedDateTime && toEpochMilli() == other.toEpochMilli();
}