lastDateAs method

Date lastDateAs(
  1. int weekday, {
  2. bool returnIfToday = false,
})

Implementation

Date lastDateAs(int weekday, {bool returnIfToday = false}) {
  Date start = this;

  if (start.weekday == weekday) {
    return returnIfToday ? start : start.addDays(-7);
  }

  while (start.weekday != weekday) {
    start = start.addDays(-1);
  }

  return start;
}