CalendarApi

View as Markdown

Calendar, holiday and working-day helpers.

Working days are derived from calendarOptions: a day is working when it is not a configured weekend day and not a configured holiday.

TypeScript
export interface

Methods

MethodReturnsDescription
getNextWorkingDay(from)DateReturns the next working day after from (defaults to today).
Never returns from itself.
getPreviousWorkingDay(from)DateReturns the previous working day before from (defaults to today).
Never returns from itself.
getWeekStartsOn()numberFirst day of the week for week-number / start-of-week Expression Functions
(calendarOptions.weekStartsOn, default 0 = Sunday).
isHoliday(dateToCheck)booleanTrue when the date is in the configured holiday list.
Weekends are not holidays unless also listed in calendarOptions.holidays.
isSameDay(date1, date2)booleanReturns true if both dates are the same calendar day (time ignored).
isToday(dateToCheck)booleanReturns true if the given date is today
isTomorrow(dateToCheck)booleanReturns true if the given date is tomorrow
isWeekend(dateToCheck)booleanTrue when the date falls on a configured weekend day
(calendarOptions.weekendDays, default Saturday/Sunday).
isWorkingDay(dateToCheck)booleanTrue when the date is neither a weekend day nor a configured holiday.
isYesterday(dateToCheck)booleanReturns true if the given date is yesterday

Method Details

getNextWorkingDay

Returns the next working day after from (defaults to today). Never returns from itself.

TypeScript
getNextWorkingDay(from?: Date): Date;
Parameters
ParameterTypeDescription
fromDateOptional start date (defaults to today)
Returns

The next working day after from (defaults to today). Never returns from itself

Date

getPreviousWorkingDay

Returns the previous working day before from (defaults to today). Never returns from itself.

TypeScript
getPreviousWorkingDay(from?: Date): Date;
Parameters
ParameterTypeDescription
fromDateOptional start date (defaults to today)
Returns

The previous working day before from (defaults to today). Never returns from itself

Date

getWeekStartsOn

First day of the week for week-number / start-of-week Expression Functions (calendarOptions.weekStartsOn, default 0 = Sunday).

TypeScript
getWeekStartsOn(): number;
Returns

First day of the week for week-number / start-of-week Expression Functions (calendarOptions.weekStartsOn, default 0 = Sunday)

number

isHoliday

True when the date is in the configured holiday list. Weekends are not holidays unless also listed in calendarOptions.holidays.

TypeScript
isHoliday(dateToCheck: Date): boolean;
Parameters
ParameterTypeDescription
dateToCheckDateDate to check
Returns

True when the date is in the configured holiday list. Weekends are not holidays unless also listed in calendarOptions.holidays

boolean

isSameDay

Returns true if both dates are the same calendar day (time ignored).

TypeScript
isSameDay(date1: Date, date2: Date): boolean;
Parameters
ParameterTypeDescription
date1Date1st Date
date2Date2nd Date
Returns

true when both dates are the same calendar day (time ignored)

boolean

isToday

Returns true if the given date is today

TypeScript
isToday(dateToCheck: Date): boolean;
Parameters
ParameterTypeDescription
dateToCheckDateDate to Check
Returns

true when the given date is today

boolean

isTomorrow

Returns true if the given date is tomorrow

TypeScript
isTomorrow(dateToCheck: Date): boolean;
Parameters
ParameterTypeDescription
dateToCheckDateDate to Check
Returns

true when the given date is tomorrow

boolean

isWeekend

True when the date falls on a configured weekend day (calendarOptions.weekendDays, default Saturday/Sunday).

TypeScript
isWeekend(dateToCheck: Date): boolean;
Parameters
ParameterTypeDescription
dateToCheckDateDate to check
Returns

True when the date falls on a configured weekend day (calendarOptions.weekendDays, default Saturday/Sunday)

boolean

isWorkingDay

True when the date is neither a weekend day nor a configured holiday.

TypeScript
isWorkingDay(dateToCheck: Date): boolean;
Parameters
ParameterTypeDescription
dateToCheckDateDate to check
Returns

True when the date is neither a weekend day nor a configured holiday

boolean

isYesterday

Returns true if the given date is yesterday

TypeScript
isYesterday(dateToCheck: Date): boolean;
Parameters
ParameterTypeDescription
dateToCheckDateDate to Check
Returns

true when the given date is yesterday

boolean