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. Audited: 2026-06-12 11:26 EDT
Implementation
@useResult
DateTime mostRecentWeekday(int weekdayTarget) =>
// Steps back 0..6 days; underflow into the previous month is intended.
DateTime(year, month, day - (weekday - weekdayTarget) % DateConstants.daysPerWeek);