Functional Weave
Code in Python

dates.add-business-days@1.0.0

README.md

1,689 bytes · view raw

# dates.add-business-days

The n-th working day after a date: Friday plus one working day is Monday, and
so is Saturday plus one. Working days are Monday to Friday minus the holidays
you pass. This is spreadsheet WORKDAY: the start date itself is never counted,
whether or not it is a working day, and a negative count walks backwards the
same way (Monday minus one is the previous Friday).

Zero returns the date unchanged, even on a Saturday. "Roll to the next working
day" is a different operation with its own conventions (following, modified
following, preceding); zero here means no move.

It agrees with dates.business-days-between: from a working day `d`,
businessDaysBetween(d, addBusinessDays(d, n, h), h) is n.

**Holidays are an argument, not a region.** Taking an explicit list keeps this
capability universal: it works for any country, for an employer's own closure
days, and for a court or exchange calendar, none of which a region code could
express. For UK bank holidays, fetch them with dates.bank-holidays for each
year the move can span and pass the dates in. That composition is a caller's
choice rather than a dependency, so the capability never ships holiday data a
caller did not ask for, and a year missing from that data fails in
dates.bank-holidays, loudly, instead of here, quietly.

Holidays that fall at a weekend are not skipped twice, duplicates are harmless,
and every holiday is validated even if the move never reaches it, so a typo in
a calendar fails on the next run.

Pass enough holiday years. Moving 10 working days from 21 December needs the
next January's holidays too; a list that stops at 31 December will count New
Year's Day as a working day.