weeksUntil method

Iterable<Hora> weeksUntil(
  1. Hora end, {
  2. WeekConfig config = WeekConfig.iso,
})

Generates week start dates from this date to end (inclusive).

Implementation

Iterable<Hora> weeksUntil(
  Hora end, {
  WeekConfig config = WeekConfig.iso,
}) sync* {
  if (!isValid) {
    throw ArgumentError.value(
      this,
      'this',
      'weeksUntil() requires a valid start Hora.',
    );
  }
  if (!end.isValid) {
    throw ArgumentError.value(
      end,
      'end',
      'weeksUntil() requires a valid end Hora.',
    );
  }

  var current = startOfWeek(config: config);
  final endWeek = end.startOfWeek(config: config);

  while (!current.isAfter(endWeek)) {
    yield current;
    current = current.add(1, TemporalUnit.week);
  }
}