nextBusinessDay
Signature
Section titled “Signature”nextBusinessDay(value: string, calendar: BusinessCalendar): stringReturn the first working day strictly after value.
- Strictly after: called on a working day it returns the next one, never
valueitself. For the on-or-after behaviour — leave a working day alone, move a non-working one forward — userollDate(value, "following", calendar). - Equivalent to
addBusinessDays(value, 1, calendar)for any valid calendar, but the calendar is required here: there is no Saturday–Sunday default to fall back on, because a weekend is never assumed. valuemay be any local date, working or not: being called from a weekend or a holiday is the normal case, not an error.valueandcalendar.holidaysare local dates;calendar.timeZoneis not read. A caller holding an instant reduces it to a local date first, withfloorToZone.- Returns
""whenvalueis not a valid ISO PlainDate, whencalendaris not a validBusinessCalendar, and when the walk runs past 200,000 calendar days without finding a working day.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO PlainDate string to start from, excluded from the search |
calendar | BusinessCalendar | BusinessCalendar naming the weekend days and holidays |
Returns
Section titled “Returns”ISO PlainDate string of the next working day, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { nextBusinessDay } from "@northguild/gmt/calendar/business";
nextBusinessDay("2024-07-03", { weekend: [6, 7], holidays: ["2024-07-04"], timeZone: "America/New_York" }) // "2024-07-05" — skips the holiday