mostRecentWeekday method
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);