The base class for calendars.
Calendars are required when working with functions that require knowledge of weekends and holidays (e.g. addBusinessDays).
There is a tutorial here.
Two calendar classes are defined: WeekendCalendar and HolidayCalendar. The object calWeekends is the default calendar. It simply defines Saturday and Sunday as holiday dates.
This is how the WeekendCalendar is defined.
import { Calendar, DateTz } from '@jetblack/date-tz'export class WeekendCalendar extends Calendar { #weekends: number[] constructor(name: string = 'WeekendCalendar', weekends: number[] = [0, 6]) { super(name) this.#weekends = weekends } isWeekend(date: DateTz): boolean { const dayOfWeek = date.weekday return this.#weekends.some(x => x === dayOfWeek) } isHoliday(date: DateTz): boolean { return this.isWeekend(date) }}
Construct a calendar.
The calendar name.
Get the calendar name.
Check if the date is a holiday.
The date to check.
True if the date is a holiday, otherwise false.
Generated using TypeDoc
The base class for calendars.
Calendars are required when working with functions that require knowledge of weekends and holidays (e.g. addBusinessDays).
There is a tutorial here.
Two calendar classes are defined: WeekendCalendar and HolidayCalendar. The object calWeekends is the default calendar. It simply defines Saturday and Sunday as holiday dates.
This is how the WeekendCalendar is defined.