isWeek static method
is Week. 是否是本周.
Implementation
static bool isWeek({required DateTime dateTime}) {
int targetMill = dateTime.millisecondsSinceEpoch;
DateTime nowDateTime = DateTime.now();
DateTime currentDateTime = DateTime(nowDateTime.year, nowDateTime.month, nowDateTime.day);
///获取现在是周几
int currentWeekDay = currentDateTime.weekday;
const oneDayTime = 60*60*24*1000;
///本周一
int monday = currentDateTime.millisecondsSinceEpoch - (oneDayTime * (currentWeekDay - 1));
///下周一
int nextMonday = currentDateTime.millisecondsSinceEpoch + (oneDayTime * (8 - currentWeekDay));
return targetMill > monday && targetMill < nextMonday;
}