# monthDayToDate

:::caution[Unreleased]
Not in `@northguild/gmt` 1.20.0 on npm yet. It is on `main` and ships in the next release.
:::

## Signature

```ts
monthDayToDate(monthDay: string, year: number): string
```

The ISO date of a month-day in a given year.

- `--02-29` in a year that is not a leap year gives 28 February. This is the ~constrain~ step of Temporal's `PlainMonthDay.prototype.toPlainDate` (CalendarDateFromFields with ~constrain~). The result is never 1 March and never `""`.
- `year` must be an integer. A fractional, string or `bigint` year gives `""`; Temporal would truncate or coerce it, and gmt does not.
- Only the ISO calendar is read; a month-day with another calendar annotation gives `""`.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `monthDay` | `string` | a month-day, `--MM-DD` or `MM-DD` |
| `year` | `number` | an integer, as Temporal's ISO calendar counts it: 0 is 1 BCE and -1 is 2 BCE |

## Returns

the ISO date, or `""` when `monthDay` is not a valid month-day, `year` is not an integer, or the date falls outside the PlainDate range

## Examples

```ts
import { monthDayToDate } from "@northguild/gmt/plain/convert";

monthDayToDate("--12-25", 2024) // "2024-12-25"
```

## Source

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