upcoming static method

List<DateTime> upcoming(
  1. DateTime at,
  2. URepeat repeat,
  3. URepeatCalendar calendar,
  4. int count,
)

Next fire times after now (at most count). Every occurrence is computed from at itself, so "the 31st" stays the 31st (or the month's last day) instead of drifting to the 28th.

Implementation

static List<DateTime> upcoming(DateTime at, URepeat repeat, URepeatCalendar calendar, int count) {
  final DateTime now = DateTime.now();
  if (repeat == URepeat.none) return at.isAfter(now) ? <DateTime>[at] : <DateTime>[];
  int k = _estimate(at, now, repeat);
  while (k > 0 && occurrence(at, repeat, calendar, k - 1).isAfter(now)) {
    k--;
  }
  while (!occurrence(at, repeat, calendar, k).isAfter(now)) {
    k++;
  }
  return <DateTime>[for (int i = 0; i < count; i++) occurrence(at, repeat, calendar, k + i)];
}