weekNumber static method

int weekNumber(
  1. DateTime date
)

Returns the ISO week number for the given date.

Implementation

static int weekNumber(DateTime date) {
  final firstJan = DateTime(date.year, 1, 1);
  final dayOfYear = date.difference(firstJan).inDays;
  return ((dayOfYear - date.weekday + 10) / 7).floor();
}