isBusinessDay
Signature
Section titled “Signature”isBusinessDay(value: string, calendar?: BusinessCalendar): booleanReturn true when value is a working day in calendar.
calendarnames the weekend days and holidays that make a date non-working. Omit it and GMT keeps its original fixed Monday–Friday week with no holidays.- Pass a calendar anywhere the weekend is not Saturday–Sunday. Much of the Middle East is Friday–Saturday and some markets keep a one-day weekend; the no-calendar form assumes Saturday–Sunday and is wrong for them.
valueandcalendar.holidaysare local dates.calendar.timeZoneis not read: it records which locality the calendar describes, so that a caller holding an instant knows which zone to reduce it in — withfloorToZoneorgetZonedDateTimeFields— before asking this question.- Returns false if
valueis not a valid ISO PlainDate, orcalendaris not a validBusinessCalendar. Narrow a calendar first withisValidBusinessCalendarto tell a misconfigured calendar apart from a genuine non-working day. This is the locale-agnostic complement to the locale-awareisWeekend:isWeekendresolves weekend days per locale viaIntl.Locale.prototype.weekInfo, whereasisBusinessDayuses the weekend the caller states, or Monday–Friday when they state none.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO PlainDate string |
calendar | BusinessCalendar | optional BusinessCalendar; defaults to Monday–Friday with no holidays |
Returns
Section titled “Returns”true if value is a working day, false on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { isBusinessDay } from "@northguild/gmt/plain/compare";
isBusinessDay("2024-02-05") // true (Monday)