firstDayInWeek method
本周第一天
firstWeekDay
- 设置每周起始日, assert(firstWeekDay > 0 && firstWeekDay < 7)
Implementation
DateTime firstDayInWeek([int firstWeekDay = 1]) {
assert(firstWeekDay > 0 && firstWeekDay < 7);
DateTime _day =
this.subtract(Duration(days: (7 + weekday - firstWeekDay) % 7));
return DateTime(_day.year, _day.month, _day.day);
}