nearestBusinessDay method
Returns the nearest business day.
If this is a business day, returns this. Otherwise, returns whichever is closer: the next or previous business day. If equidistant, prefers the next business day.
Implementation
Hora nearestBusinessDay([
BusinessDayConfig config = BusinessDayConfig.standard,
]) {
if (isBusinessDay(config)) return this;
final next = nextBusinessDay(config);
final prev = previousBusinessDay(config);
final daysToNext = next.diff(this, TemporalUnit.day).abs();
final daysToPrev = diff(prev, TemporalUnit.day).abs();
return daysToNext <= daysToPrev ? next : prev;
}