isThisWeek method
根据时间戳判断是否是本周
Implementation
bool isThisWeek({bool isUtc = false}) {
var ms = this;
if (ms == null || ms <= 0) {
return false;
}
DateTime oldDay = DateTime.fromMillisecondsSinceEpoch(ms, isUtc: isUtc);
DateTime nowDat = isUtc ? DateTime.now().toUtc() : DateTime.now().toLocal();
DateTime old = nowDat.millisecondsSinceEpoch > oldDay.millisecondsSinceEpoch
? oldDay
: nowDat;
DateTime now = nowDat.millisecondsSinceEpoch > oldDay.millisecondsSinceEpoch
? nowDat
: oldDay;
return (now.weekday >= old.weekday) &&
(now.millisecondsSinceEpoch - old.millisecondsSinceEpoch <=
7 * DateUtils.oneDay);
}