# startOfDate

Industry: Core

## Signature

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

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

- `"day"` returns the date itself: a date is already a whole day, as `endOfDate` treats it.
- `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 start |

## 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 start of the specified unit, or "" on invalid input

## Examples

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

startOfDate("2024-02-29", "month") // "2024-02-01"
```

## Source

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