isValidBusinessCalendar
Signature
Section titled “Signature”isValidBusinessCalendar(calendar: unknown): calendar is BusinessCalendarReturn true when calendar is a BusinessCalendar the business-day functions accept.
weekendmust be an array of ISO weekday integers, 1 (Monday) through 7 (Sunday). Duplicates are ignored and[]is valid — a calendar with no weekly closure.- All seven weekdays being weekend is invalid: such a calendar has no business day, so
nextBusinessDayand every other walk would have nothing to walk to. holidaysmust be an array of ISO PlainDate strings.[]is valid. A datetime, a leap second or a date that does not exist is not.timeZonemust be a valid IANA identifier. It records which locality the calendar describes; the business-day functions never read it, because they work on local dates.- Returns
falsefor non-objects,nulland arrays. - Use it to tell a legitimate result from
mergeCalendarsapart from its invalid-input sentinel, which is alsonull, and to tell a misconfigured calendar apart from a bad date when a business-day function returns"".
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
calendar | unknown | candidate value of any type |
Returns
Section titled “Returns”boolean indicating whether every business-day function accepts it
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isValidBusinessCalendar } from "@northguild/gmt/calendar/validate";
isValidBusinessCalendar({ weekend: [6, 7], holidays: [], timeZone: "UTC" }) // true