nextWeekday method

DateTime nextWeekday(
  1. int weekday
)

Returns new DateTime instance of nearest nth weekday in the future

If nth day is today, will return 7 days in the future.

Implementation

DateTime nextWeekday(int weekday) {
  assert(weekday > -1 && weekday < 8,
      "[moment_dart] Weekday must be in range `0<=n<=7`");

  final int requiredDelta = (weekday - this.weekday) % 7;

  return this + Duration(days: requiredDelta == 0 ? 7 : requiredDelta);
}