Holiday Calendars

Summary

  • AdapTable allows developers to provide custom Holiday Calendars
  • These are used when evaluating System Predicates which reference Holidays
  • Holidays can be provided either as a list of Dates or via a function

Providing Holiday Calendars

AdapTable provides 4 Date-related System Predicates which reference Holidays:

  • NextWorkDay
  • LastWorkDay
  • WorkDay
  • Holiday

Each of these Predicates will take any bespoke Holidays into account during evaluation.

Note

By default AdapTable will only count non-weekdays as Holidays.

Caution

  • AdapTable has no internal knowledge of any Public Holidays - even major ones like New Year's Day
  • It is the job of the developer to provide the custom holidays for each user

Holidays are provided using the holidays property in Calendar Options.

holidays

string[]
Holidays - used to determine Working Days

Providing a List of Holidays

The simplest way to provide Holidays is as a list of dates in ISO string format:

// Set Christmas and New Year as Public Holidays
const adaptableOptions: AdaptableOptions = {
  calendarOptions: {
    holidays: ['2022-12-25', '2023-01-01'],
  },
}

Providing a Function

Alternatively a JavaScript function can be provided when using the holidays property.

Note

This takes precedence over the list option

The function receives an object of type BaseContext and returns a list of Dates.

The function can be used like this:

// Set Christmas and New Year as Public Holidays
const adaptableOptions: AdaptableOptions = {
  calendarOptions: {
    holidays: (baseContext: BaseContext) => {
      return [new Date(2022, 11, 25), new Date(2023, 0, 1)]
    },
  },
}

Providing Custom Holidays
Fork
  • This demo shows how to provide AdapTable with custom holidays
  • We provide all dates between 22 December 2020 and 3 January 2021
  • We provide 3 Holiday Dates: Christmas Day (25 Dec), Boxing Day (26 Dec) and New Years Day (1 Jan)
  • We set the Layout to show the WorkDay Predicate, and the Column does not include the 3 holidays

Expand to see Calendar definitions

Using Holiday Calendars

(Recorded with AdapTable v13.1)

Technical Reference

Calendar Options

Calendar Section of Adaptable Options contains the calendars property:

PropertyDescriptionDefault
holidaysHolidays for current Usernull

Calendar API

Calendar Section of Adaptable API contains functions relating to Calendars, Holidays and Working Days in AdapTable

MethodDescription
getNextWorkingDay()Returns the next Working Day
getPreviousWorkingDay()Returns the previous Working Day
isHoliday(dateToCheck)Checks if given data is a Holiday
isSameDay(date1, date2)Returns true if both Dates are the same, ignoring the time portions
isWorkingDay(dateToCheck)Checks if given date is a Working Day