adjustToWorkday static method

DateTime adjustToWorkday(
  1. DateTime date, {
  2. required bool isNext,
})

Adjusts a date to the next or previous workday.

Implementation

static DateTime adjustToWorkday(DateTime date, {required bool isNext}) {
  const workdays = EveryWeekday.workdays;
  if (workdays.valid(date)) return date;
  if (isNext) return workdays.next(date);
  return workdays.previous(date);
}