@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
17 lines • 792 B
TypeScript
/**
* Return the year-month (`YYYY-MM`) of an ISO 8601 date string.
*
* - The day is dropped, so `2026-10-01` and `2026-10-31` give the same year-month.
* - Only the ISO calendar is read; a Hebrew or Islamic date gives `""`.
* - Returns "" for invalid input.
*
* @param value ISO date string
* @returns The canonical `YYYY-MM` string (`±YYYYYY-MM` outside 0000-9999), or "" on invalid input
*
* @example parseYearMonthFromDate("2026-10-01") // "2026-10"
* @example parseYearMonthFromDate("2026-10-31") // "2026-10"
* @example parseYearMonthFromDate("+275760-09-13") // "+275760-09"
* @example parseYearMonthFromDate("2023-02-29") // ""
* @example parseYearMonthFromDate("2026-10-01[u-ca=hebrew]") // ""
*/
export declare function parseYearMonthFromDate(value: string): string;