tt_PREVWDAY function
dynamic
tt_PREVWDAY(
- dynamic v1,
- dynamic v2
tt_PREVWDAY(date, dow): finds the previous occurrence of the given weekday before date
Implementation
dynamic tt_PREVWDAY(dynamic v1, dynamic v2) {
final d = _vToDateTime(v1);
if (d == null) return null;
final target = varToInt(v2);
var diff = d.weekday - target;
if (diff <= 0) diff += 7;
return d.subtract(Duration(days: diff));
}