///国际规定是周四为一周的第一天 const int WEEK_DAY = DateTime.thursday; String getWeek(DateTime dateTime) { ///当前选中时间 周几 var currentWeekDay = dateTime.weekday; ///周四 int WEEK_DAY = DateTime.thursday; DateTime epoch = DateTime.utc(dateTime.year); int offset = EPOCH_WEEK_DAY - currentWeekDay; int delta = - offset; int week = (dateTime.difference(epoch).inDays - delta) ~/ 7 + 1; return intToStr(week); } String intToStr(int v) { return (v < 10) ? "0$v" : "$v"; }
///周,如果当年的12月31是周四,则当年有53周 (国际规定是周四为一周的第一天)