getIndexWeekInMonth static method

int getIndexWeekInMonth(
  1. DateTime dateTime
)

本月的第几周

Implementation

static int getIndexWeekInMonth(DateTime dateTime) {
  DateTime firstdayInMonth = new DateTime(dateTime.year, dateTime.month, 1);
  Duration duration = dateTime.difference(firstdayInMonth);
  // return (duration.inDays / 7).toInt() + 1;
  return (duration.inDays ~/ 7) + 1;
}