eachDay method

Iterable<DateTime> eachDay(
  1. DateTime date, {
  2. bool ignoreDaylightSavings = false,
})

Return an Iterable of dates which is inclusive to this but exclusive to date

Implementation

Iterable<DateTime> eachDay(
  DateTime date, {
  bool ignoreDaylightSavings = false,
}) sync* {
  if (isSameDay(date)) {
    yield date.startOfDay;

    return;
  }

  final daysDiff = differenceInDays(date);

  for (var i = 0; i != daysDiff; i += daysDiff.sign) {
    yield this.addDays(-i, ignoreDaylightSavings);
  }
}