Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HolidayCalendar

A calendar class which supports weekends and an array of arbitrary dates.

The following constructs a holiday calendar for the US in 2020.

import { HolidayCalendar } from '@jetblack/date'

const calUS = new HolidayCalendar(
'US',
[0, 6], // Saturday and Sunday are always holidays.
[
new Date('2020-01-01'), // Wed: New Year's Day
new Date('2020-01-20'), // Mon: Martin Luther King Jr. Day
new Date('2020-05-25'), // Mon: Memorial Day
new Date('2020-07-03'), // Fri: Independence Day
new Date('2020-09-07'), // Mon: Labor Day
new Date('2020-11-11'), // Wed: Veterans Day
new Date('2020-11-26'), // Thu: Thanksgiving
new Date('2020-12-25') // Fri: Christmas Day
]
)

Hierarchy

Index

Constructors

Accessors

Methods

Constructors

Accessors

  • get name(): string
  • Get the calendar name.

    Returns string

Methods

  • isHoliday(date: Date, tz?: Timezone): boolean
  • isWeekend(date: Date, tz?: Timezone): boolean
  • Check if the date is a weekend.

    Parameters

    • date: Date

      The date.

    • tz: Timezone = tzLocal

      An optional timezone. Defaults to the local timezone.

    Returns boolean

    True is the date is a weekend, otherwise false.

Generated using TypeDoc