nextWeekday method
Returns new DateTime instance of nearest n
th weekday in the future
If n
th 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);
}