parseYearMonth
Signature
Section titled “Signature”parseYearMonth(value: string): stringReturn the canonical YYYY-MM form of an ISO year-month string (±YYYYYY-MM outside 0000-9999).
- Reads
YYYY-MMand±YYYYYY-MM; writes the shortest form. The reference day is never written. - The extended form only:
202610is refused, asisValidDaterefuses20241225. - A date such as
2026-10-01is not a year-month: useparseYearMonthFromDate. - The range is Temporal’s:
-271821-04to+275760-09. - Annotations are read as
isValidYearMonthreads them: elective and time zone annotations are ignored, an unknown critical one refuses, andu-camust beiso8601in any case. - Returns "" for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO year-month string |
Returns
Section titled “Returns”the YYYY-MM string, or "" on invalid input
Examples
Section titled “Examples”import { parseYearMonth } from "@northguild/gmt/plain/parse";
parseYearMonth("2026-10") // "2026-10"Source
Section titled “Source”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.