getDayNumberInWeek method
Returns number of the day in week (starting with 1).
Difference from DateTime.weekday is that
you can define first weekday (Monday, Sunday or Saturday) with
parameter firstWeekday. It should be one of the constant values
DateTime.monday, ..., DateTime.sunday.
By default it's DateTime.monday.
Implementation
int getDayNumberInWeek(DateTime date, {int firstWeekday = DateTime.monday}) {
var res = date.weekday - (firstWeekday) + 1;
if (res <= 0) res += DateTime.daysPerWeek;
return res;
}