mostRecentWeekday method

DateTime mostRecentWeekday(
  1. int weekdayTarget
)

Returns the most recent occurrence of the specified weekday.

Args:

  • weekdayTarget: The target weekday (1 = Monday, 7 = Sunday).

Returns: The most recent date that falls on the target weekday.

Implementation

DateTime mostRecentWeekday(int weekdayTarget) =>
    DateTime(year, month, day - (weekday - weekdayTarget) % 7);