getDateTimeLastWeek function

Pair<DateTime> getDateTimeLastWeek([
  1. DateTimeWeekDay? weekFirstDay,
  2. DateTime? time
])

Returns start and end of last week, before current week, using time as reference.

weekFirstDay the desired first day of week for computation behavior. time if null uses DateTime.now .

Implementation

Pair<DateTime> getDateTimeLastWeek(
    [DateTimeWeekDay? weekFirstDay, DateTime? time]) {
  time ??= DateTime.now();

  var weekStart =
      getDateTimeWeekStart(weekFirstDay, time).subtract(Duration(days: 7));
  var weekEnd = getDateTimeWeekEnd(weekFirstDay, weekStart);

  return Pair(getDateTimeDayStart(weekStart), getDateTimeDayEnd(weekEnd));
}