equals method
Compares two time zones for equality according to the options and interval provided to this comparer.
x
: The first DateTimeZone to compare.
y
: The second DateTimeZone to compare.
Returns: true
if the specified time zones are equal under the options and interval of this comparer; otherwise, false
.
Implementation
bool equals(DateTimeZone x, DateTimeZone y) {
if (identical(x, y)) {
return true;
}
if (x == y) {
return true;
}
// If we ever need to port this to a platform which doesn't support LINQ,
// we'll need to reimplement this. Until then, it would seem pointless...
// Dart: that day is TODAY! todo: is this inefficient?
var ax = _getIntervals(x); //.toList(growable: false);
var by = _getIntervals(y); //.toList(growable: false);
// Need a way to know if length can be efficiently computed or not
// if (ax.length != by.length) return false;
var a = ax.iterator;
var b = by.iterator;
// if (a.length != b.length) return false;
// while(a.moveNext() || b.moveNext()) {
// if (a.current == null || b.current == null) return false;
// if (!zoneIntervalComparer.Equals(a.current, b.current)) return false;
// }
while (a.moveNext())
{
if (!b.moveNext() || !_zoneIntervalComparer.equals(a.current, b.current))
return false;
}
return !b.moveNext();
// return true;
// return GetIntervals(x).SequenceEqual(GetIntervals(y), zoneIntervalComparer);
}