getZoneIntervals method

Iterable<ZoneInterval> getZoneIntervals(
  1. Interval interval
)

Returns all the zone intervals which occur for any instant in the given interval.

The zone intervals are returned in chronological order. This method is equivalent to calling DateTimeZone.getZoneInterval for every instant in the interval and then collapsing to a set of distinct zone intervals. The first and last zone intervals are likely to also cover instants outside the given interval; the zone intervals returned are not truncated to match the start and end points.

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

Returns: A sequence of zone intervals covering the given interval.

see also: DateTimeZone.getZoneInterval

Implementation

Iterable<ZoneInterval> getZoneIntervals(Interval interval) sync* {
  var current = interval.hasStart ? interval.start : Instant.minValue;
  var end = IInterval.rawEnd(interval);
  while (current < end) {
    var zoneInterval = getZoneInterval(current);
    yield zoneInterval;
    // If this is the end of time, this will just fail on the next comparison.
    current = IZoneInterval.rawEnd(zoneInterval);
  }
}