Skip to content

year

  • The core functions, which every industry uses.
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).

import { year } from "@northguild/gmt";
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)

regex/date.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.