# year

Industry: Core

```ts
const year: RegExp = /^(?:\d{4}|\+\d{6}|-(?!0{6})\d{6})$/;
```

RegExp matching the shape of an ISO 8601 year: 4 digits, or a sign and 6 digits (Temporal's `DateYear`).

## Examples

```ts
import { year } from "@northguild/gmt";
```

```ts
year.test("2024") // true
year.test("+275760") // true (expanded year)
year.test("-271821") // true (negative expanded year)
year.test("+999999") // true (shape only; outside Temporal's range)
year.test("-000000") // false (negative zero)
year.test("24") // false (too few digits)
year.test("20245") // false (5 digits without a sign)
```

## Source

[regex/date.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/regex/date.ts)
