YearMonthRange constructor

YearMonthRange(
  1. YearMonth from,
  2. YearMonth to
)

Generate Set with all YearMonth between from and to

Throws AssertionError if from is greater than to

Implementation

YearMonthRange(YearMonth from, YearMonth to)
    : assert(from <= to),
      _ymr = _ymSetGenerator {
  int beginM = from.month;
  for (int y = from.year; y <= to.year; y++) {
    for (int m = beginM; m <= 12; m++) {
      _ymr.add(YearMonth(y, m));
      if (y == to.year && m == to.month) {
        break;
      }
    }
    beginM = 1;
  }
  assert(_ymr.length == from.compareTo(to) + 1);
}