weekNumber method

int weekNumber()

Calculates week number from a date as per https://en.wikipedia.org/wiki/ISO_week_date#Calculation

Implementation

int weekNumber() {
  int dayOfYear = int.parse(DateFormat("D").format(this));
  int woy = ((dayOfYear - weekday + 10) / 7).floor();
  if (woy < 1) {
    woy = numOfWeeks(year - 1);
  } else if (woy > numOfWeeks(year)) {
    woy = 1;
  }
  return woy;
}