# @salmonui/core/dates API reference

> 17 exported symbols of @salmonui/core/dates: 5 functions, 6 interfaces and 6 types.

Canonical: https://salmonui.dev/docs/reference/core/dates

```ts
import { … } from '@salmonui/core/dates';
```

## Functions

### getRangeDays

Kind: function

Page: https://salmonui.dev/docs/reference/core/dates/getRangeDays

```ts
function getRangeDays(range: DateRange<PlainDateLike> | null | undefined): number;
```

Inclusive number of days of a range; 0 for null.

### toDate

Kind: function

Page: https://salmonui.dev/docs/reference/core/dates/toDate

```ts
function toDate(value: PlainDateLike & Partial<PlainTimeLike>, timeZone?: string): Date;
```

The `Date` (instant) of a plain date or date-time: its wall time in
`timeZone` (DST resolved like Temporal `'compatible'`), else in the host
zone. An invalid value or zone gives an invalid `Date`.

### toPlainDate

Kind: function

Page: https://salmonui.dev/docs/reference/core/dates/toPlainDate

```ts
function toPlainDate(input: unknown, timeZone?: string): PlainDate | null;
```

Normalizes a `DateInput` (an invalid input is null; never throws).

### toPlainDateTime

Kind: function

Page: https://salmonui.dev/docs/reference/core/dates/toPlainDateTime

```ts
function toPlainDateTime(input: unknown, timeZone?: string): PlainDateTime | null;
```

Normalizes a `DateTimeInput`; a date-only input is midnight.

### toPlainTime

Kind: function

Page: https://salmonui.dev/docs/reference/core/dates/toPlainTime

```ts
function toPlainTime(input: unknown, timeZone?: string): PlainTime | null;
```

Normalizes a `TimeInput`; a date-time input keeps its time part.

## Interfaces

### DateRange

Kind: interface

Page: https://salmonui.dev/docs/reference/core/dates/DateRange

```ts
interface DateRange<T = PlainDate> {
    readonly start: T;
    readonly end: T;
}
```

An inclusive range of two values.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `start` | `readonly start: T;` |  |  |
| `end` | `readonly end: T;` |  |  |

### PlainDate

Kind: interface

Page: https://salmonui.dev/docs/reference/core/dates/PlainDate

```ts
interface PlainDate extends PlainDateLike {
    toString(): string;
    toJSON(): string;
}
```

A frozen ISO calendar date. `String(date)` and `JSON.stringify` give `YYYY-MM-DD`.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `toString` | `toString(): string;` |  | Returns a string representation of an object. |
| `toJSON` | `toJSON(): string;` |  |  |
| `year` | `year: number;` | inherited |  |
| `month` | `month: number;` | inherited |  |
| `day` | `day: number;` | inherited |  |

### PlainDateLike

Kind: interface

Page: https://salmonui.dev/docs/reference/core/dates/PlainDateLike

```ts
interface PlainDateLike {
    readonly year: number;
    readonly month: number;
    readonly day: number;
}
```

Anything with ISO calendar date fields (`Temporal.PlainDate` included). Month is 1-12.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `year` | `readonly year: number;` |  |  |
| `month` | `readonly month: number;` |  |  |
| `day` | `readonly day: number;` |  |  |

### PlainDateTime

Kind: interface

Page: https://salmonui.dev/docs/reference/core/dates/PlainDateTime

```ts
interface PlainDateTime extends PlainDate, Omit<PlainTime, 'toString' | 'toJSON'> {
}
```

A frozen date and wall-clock time. `String(value)` gives `YYYY-MM-DDTHH:mm:ss`.

Members (9):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `year` | `year: number;` | inherited |  |
| `month` | `month: number;` | inherited |  |
| `day` | `day: number;` | inherited |  |
| `hour` | `hour: number;` | inherited |  |
| `minute` | `minute: number;` | inherited |  |
| `second` | `second: number;` | inherited |  |
| `millisecond` | `millisecond: number;` | inherited |  |
| `toString` | `toString: () => string;` | inherited | Returns a string representation of an object. |
| `toJSON` | `toJSON: () => string;` | inherited |  |

### PlainTime

Kind: interface

Page: https://salmonui.dev/docs/reference/core/dates/PlainTime

```ts
interface PlainTime extends Required<PlainTimeLike> {
    toString(): string;
    toJSON(): string;
}
```

A frozen wall-clock time. `String(time)` gives `HH:mm:ss` (`.sss` when milliseconds are set).

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `toString` | `toString(): string;` |  | Returns a string representation of an object. |
| `toJSON` | `toJSON(): string;` |  |  |
| `hour` | `hour: number;` | inherited |  |
| `minute` | `minute: number;` | inherited |  |
| `second` | `second: number;` | inherited |  |
| `millisecond` | `millisecond: number;` | inherited |  |

### PlainTimeLike

Kind: interface

Page: https://salmonui.dev/docs/reference/core/dates/PlainTimeLike

```ts
interface PlainTimeLike {
    readonly hour: number;
    readonly minute: number;
    readonly second?: number;
    readonly millisecond?: number;
}
```

Anything with wall-clock time fields (`Temporal.PlainTime` included).

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `hour` | `readonly hour: number;` |  |  |
| `minute` | `readonly minute: number;` |  |  |
| `second` | `readonly second?: number;` | optional |  |
| `millisecond` | `readonly millisecond?: number;` | optional |  |

## Types

### DateInput

Kind: type

Page: https://salmonui.dev/docs/reference/core/dates/DateInput

```ts
type DateInput = PlainDateLike | Date | string;
```

A date value: fields, a `Date` (an instant, read in the time zone) or an ISO 8601 string (`'2026-11-23'`).

### DateTimeInput

Kind: type

Page: https://salmonui.dev/docs/reference/core/dates/DateTimeInput

```ts
type DateTimeInput = PlainDateTimeLike | Date | string;
```

A date-time value: fields, a `Date` or an ISO date-time string (`'2026-11-23T14:30'`).

### PlainDateTimeLike

Kind: type

Page: https://salmonui.dev/docs/reference/core/dates/PlainDateTimeLike

```ts
type PlainDateTimeLike = PlainDateLike & PlainTimeLike;
```

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `year` | `year: number;` | inherited |  |
| `month` | `month: number;` | inherited |  |
| `day` | `day: number;` | inherited |  |
| `hour` | `hour: number;` | inherited |  |
| `minute` | `minute: number;` | inherited |  |
| `second` | `second?: number;` | optional, inherited |  |
| `millisecond` | `millisecond?: number;` | optional, inherited |  |

### TimeInput

Kind: type

Page: https://salmonui.dev/docs/reference/core/dates/TimeInput

```ts
type TimeInput = PlainTimeLike | Date | string;
```

A time value: fields, a `Date` or an ISO time string (`'14:30'`, `'14:30:05'`).

### WeekRule

Kind: type

Page: https://salmonui.dev/docs/reference/core/dates/WeekRule

```ts
type WeekRule = 'firstDay' | 'firstFullWeek' | 'firstFourDayWeek';
```

Which week of January is week 1.

### WeekdayFormat

Kind: type

Page: https://salmonui.dev/docs/reference/core/dates/WeekdayFormat

```ts
type WeekdayFormat = 'narrow' | 'short' | 'long';
```
