# endOfDate

Industry: Core

## Signature

```ts
endOfDate(value: string, unit: SmallestUnit<DateUnit>, optionsArg?: { weekStartsOn?: "monday" | "sunday"; }): string
```

Return the end of the specified date `unit` for a given ISO 8601 date string.

- The end is computed forward from `value`, so it is returned even when the unit began before the first representable date (`-271821-04-19`).
- `unit` accepts the singular or plural name (`"month"` or `"months"`), as Temporal does.
- Returns "" for invalid inputs.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | ISO 8601 date string |
| `unit` | `SmallestUnit<DateUnit>` | date unit, singular or plural, to specify the unit for the end |

## Options

**optionsArg**

How the week is defined

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `weekStartsOn?` | `"monday"` \| `"sunday"` | `"monday"` | The first day of the week, which sets where a `"week"` unit starts. `"monday"` is the ISO 8601 week, Monday to Sunday; `"sunday"` runs Sunday to Saturday. Any other value returns `""`, whatever the unit. |

## Returns

ISO 8601 string representing the end of the specified unit, or "" on invalid input

## Examples

```ts
import { endOfDate } from "@northguild/gmt/plain/calculate";

endOfDate("2024-02-29", "month") // "2024-02-29"
```

## Source

[plain/calculate/endOfDate.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/plain/calculate/endOfDate.ts)
