getZoneIntervalsOptions method

Iterable<ZoneInterval> getZoneIntervalsOptions(
  1. Interval interval,
  2. ZoneEqualityComparerOptions options
)

Returns the zone intervals within the given interval, potentially coalescing some of the original intervals according to options.

This is equivalent to GetZoneIntervals(Interval), but may coalesce some intervals. For example, if the ZoneEqualityComparer.Options.OnlyMatchWallOffset is specified, and two consecutive zone intervals have the same offset but different names, a single zone interval will be returned instead of two separate ones. When zone intervals are coalesced, all aspects of the first zone interval are used except its end instant, which is taken from the second zone interval.

As the options are only used to determine which intervals to coalesce, the ZoneEqualityComparer.Options.MatchStartAndEndTransitions option does not affect the intervals returned.

  • interval: Interval to find zone intervals for. This is allowed to be unbounded (i.e. infinite in both directions).
  • options:

Implementation

// todo: merge with regular getZoneIntervals as a custom parameter
Iterable<ZoneInterval> getZoneIntervalsOptions(Interval interval, ZoneEqualityComparerOptions options) {
  if ((options & ~ZoneEqualityComparerOptions.strictestMatch).value != 0) {
    throw ArgumentError('The value $options is not defined within ZoneEqualityComparer.Options');
  }
  var zoneIntervalEqualityComparer = ZoneIntervalEqualityComparer(options, interval);
  var originalIntervals = getZoneIntervals(interval);
  return zoneIntervalEqualityComparer.coalesceIntervals(originalIntervals);
}