getDateTimeWeekEnd function

DateTime getDateTimeWeekEnd([
  1. DateTimeWeekDay? weekFirstDay,
  2. DateTime? now
])

Returns the end of the week using time as reference.

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

Implementation

DateTime getDateTimeWeekEnd([DateTimeWeekDay? weekFirstDay, DateTime? now]) {
  weekFirstDay ??= DateTimeWeekDay.monday;
  now ??= DateTime.now();

  var weekStart = getDateTimeWeekStart(weekFirstDay, now);

  var weekEnd = weekStart.add(Duration(days: 6)).add(Duration(hours: 12));

  return getDateTimeDayEnd(weekEnd);
}