DateInterval constructor
DateInterval({})
Creates an instance of the DateInterval class.
period
must be greater than 0 or it will throw an ArgumentError.
Implementation
DateInterval({
DateTime? startDate,
DateTime? endDate,
this.period = 1,
this.interval = Intervals.once,
Iterable<DateTime>? skipDates,
Iterable<int>? additionalDaysOfTheMonth,
}) {
if (period < 1) {
throw ArgumentError.value(
period, 'period', 'Period must be 1 or greater.');
}
if (skipDates != null) {
this.skipDates.addAll(skipDates);
}
this.startDate = startDate == null
? DateTime.now().withZeroTime()
: startDate.withZeroTime();
this.endDate = endDate?.withZeroTime();
for (final day in additionalDaysOfTheMonth ?? <int>[]) {
if (day < 1 || day > 31) continue;
if (additionalDates.contains(day) || day == startDate!.day) continue;
additionalDates.add(day);
}
}