lastWeekday method

DateTime lastWeekday(
  1. int weekday
)

Returns new DateTime instance of last nth weekday

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

Implementation

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

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

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