isLongWeekend method
Checks if this is part of a "long" weekend (3+ consecutive non-working days).
Without isHoliday, a standard Saturday-Sunday weekend is only 2 days,
so this always returns false. Provide isHoliday to include holidays
(e.g., a Friday or Monday holiday creates a 3-day weekend).
Implementation
bool isLongWeekend({bool Function(Hora)? isHoliday}) {
bool isNonWorking(Hora date) {
if (date.isWeekend) return true;
return isHoliday?.call(date) ?? false;
}
if (!isNonWorking(this)) return false;
var count = 1;
var next = add(1, TemporalUnit.day);
while (isNonWorking(next)) {
count++;
if (count >= 3) return true;
next = next.add(1, TemporalUnit.day);
}
var prev = subtract(1, TemporalUnit.day);
while (isNonWorking(prev)) {
count++;
if (count >= 3) return true;
prev = prev.subtract(1, TemporalUnit.day);
}
return false;
}