week property

int get week

Returns ISO week number of the year

1, 2, 3, ..., 52, 53

Implementation

int get week {
  final int w = _isoWeekRaw;

  // Last year may have 52 or 53 weeks, we shall check
  //
  // Dec 28 is always in the last week
  if (w == 0) {
    return DateTime(year - 1, 12, 28).week;
  }

  // It might actually be [Week 1] in the next year
  if (w == 53 && _isoWeekInNextYear) {
    return 1;
  }

  return w;
}