# parseYearMonth

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

## Signature

```ts
parseYearMonth(value: string): string
```

Return the canonical `YYYY-MM` form of an ISO year-month string (`±YYYYYY-MM` outside 0000-9999).

- Reads `YYYY-MM` and `±YYYYYY-MM`; writes the shortest form. The reference day is never written.
- The extended form only: `202610` is refused, as `isValidDate` refuses `20241225`.
- A date such as `2026-10-01` is not a year-month: use `parseYearMonthFromDate`.
- The range is Temporal's: `-271821-04` to `+275760-09`.
- Annotations are read as `isValidYearMonth` reads them: elective and time zone annotations are ignored, an unknown critical one refuses, and `u-ca` must be `iso8601` in any case.
- Returns "" for invalid input.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `value` | `string` | ISO year-month string |

## Returns

the `YYYY-MM` string, or "" on invalid input

## Examples

```ts
import { parseYearMonth } from "@northguild/gmt/plain/parse";

parseYearMonth("2026-10") // "2026-10"
```

## Source

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