# CalendarApi

Canonical page: https://www.adaptabletools.com/docs/reference/calendarapi

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.

```ts title="TypeScript"
export interface CalendarApi 
```

## Methods

| Method | Returns | Description |
| --- | --- | --- |
| [getNextWorkingDay(from)](https://www.adaptabletools.com/docs/reference/calendarapi.md#getnextworkingday) | `Date` | Returns the next working day after `from` (defaults to today).<br/>Never returns `from` itself. |
| [getPreviousWorkingDay(from)](https://www.adaptabletools.com/docs/reference/calendarapi.md#getpreviousworkingday) | `Date` | Returns the previous working day before `from` (defaults to today).<br/>Never returns `from` itself. |
| [getWeekStartsOn()](https://www.adaptabletools.com/docs/reference/calendarapi.md#getweekstartson) | `number` | First day of the week for week-number / start-of-week Expression Functions<br/>(`calendarOptions.weekStartsOn`, default `0` = Sunday). |
| [isHoliday(dateToCheck)](https://www.adaptabletools.com/docs/reference/calendarapi.md#isholiday) | `boolean` | True when the date is in the configured holiday list.<br/>Weekends are not holidays unless also listed in `calendarOptions.holidays`. |
| [isSameDay(date1, date2)](https://www.adaptabletools.com/docs/reference/calendarapi.md#issameday) | `boolean` | Returns true if both dates are the same calendar day (time ignored). |
| [isToday(dateToCheck)](https://www.adaptabletools.com/docs/reference/calendarapi.md#istoday) | `boolean` | Returns true if the given date is today |
| [isTomorrow(dateToCheck)](https://www.adaptabletools.com/docs/reference/calendarapi.md#istomorrow) | `boolean` | Returns true if the given date is tomorrow |
| [isWeekend(dateToCheck)](https://www.adaptabletools.com/docs/reference/calendarapi.md#isweekend) | `boolean` | True when the date falls on a configured weekend day<br/>(`calendarOptions.weekendDays`, default Saturday/Sunday). |
| [isWorkingDay(dateToCheck)](https://www.adaptabletools.com/docs/reference/calendarapi.md#isworkingday) | `boolean` | True when the date is neither a weekend day nor a configured holiday. |
| [isYesterday(dateToCheck)](https://www.adaptabletools.com/docs/reference/calendarapi.md#isyesterday) | `boolean` | Returns true if the given date is yesterday |

## Method Details

### getNextWorkingDay

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

```ts title="TypeScript"
getNextWorkingDay(from?: Date): Date;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| from | `Date` | Optional 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.

```ts title="TypeScript"
getPreviousWorkingDay(from?: Date): Date;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| from | `Date` | Optional 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).

```ts title="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`.

```ts title="TypeScript"
isHoliday(dateToCheck: Date): boolean;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dateToCheck | `Date` | Date 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).

```ts title="TypeScript"
isSameDay(date1: Date, date2: Date): boolean;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| date1 | `Date` | 1st Date |
| date2 | `Date` | 2nd Date |

###### Returns

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

`boolean`

### isToday

Returns true if the given date is today

```ts title="TypeScript"
isToday(dateToCheck: Date): boolean;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dateToCheck | `Date` | Date to Check |

###### Returns

 `true` when the given date is today

`boolean`

### isTomorrow

Returns true if the given date is tomorrow

```ts title="TypeScript"
isTomorrow(dateToCheck: Date): boolean;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dateToCheck | `Date` | Date 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).

```ts title="TypeScript"
isWeekend(dateToCheck: Date): boolean;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dateToCheck | `Date` | Date 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.

```ts title="TypeScript"
isWorkingDay(dateToCheck: Date): boolean;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dateToCheck | `Date` | Date 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

```ts title="TypeScript"
isYesterday(dateToCheck: Date): boolean;
```

###### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dateToCheck | `Date` | Date to Check |

###### Returns

 `true` when the given date is yesterday

`boolean`
