getISOWeek property
int
getISOWeek
Get the ISO week index
Implementation
int get getISOWeek {
final woy = (_ordinalDate - weekday + 10) ~/ 7;
// If the week number equals zero, it means that the given date belongs to the preceding (week-based) year.
if (woy == 0) {
// The 28th of December is always in the last week of the year
return Date(year: year - 1, month: 12, day: 28).getISOWeek;
}
// If the week number equals 53, one must check that the date is not actually in week 1 of the following year
if (woy == 53 &&
DateTime(year).weekday != DateTime.thursday &&
DateTime(year, 12, 31).weekday != DateTime.thursday) {
return 1;
}
return woy;
}