getWeekOfMonth method
The ordinal number of the week within the month.
Resolves the first day of the week from locale internally (via
ILibLocaleInfo.getFirstDayOfWeek), rather than taking a pre-resolved
value.
Implementation
@override
int getWeekOfMonth(String? locale) {
final int firstDayOfWeek = ILibLocaleInfo(locale).getFirstDayOfWeek();
final ILibRataDie first = HebrewRataDie(
year: _year,
month: _month,
day: 1,
hour: 18,
minute: 0,
second: 0,
millisecond: 0,
);
final double rd = _rataDie.getRataDie();
double weekStart = first.onOrAfter(firstDayOfWeek);
if (weekStart - first.getRataDie() > 3) {
weekStart -= 7;
}
if (rd < weekStart) {
return 0;
}
return (rd - weekStart) ~/ 7 + 1;
}