@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.
21 lines • 1.03 kB
TypeScript
/**
* Write an ISO year as Temporal writes it at the head of a date string (TC39 Temporal
* `PadISOYear ( y )`, §3.5.10): four digits from 0000 to 9999, otherwise a sign and six digits.
*
* A year written any other way does not read back. `"10000-01-01"` and `"00-5-01-01"` are not ISO
* 8601 or Temporal strings, and `isValidDate` rejects both; `"+010000-01-01"` and
* `"-000005-01-01"` are what `Temporal.PlainDate#toString` writes.
*
* - Every function that returns a year on its own writes it this way.
* - Where a Temporal value is at hand, let its own `toString` write the whole date. This is for a
* year on its own, or a date assembled from fields with no Temporal value behind them.
*
* @param year an ISO year, an integer
* @returns the year as `YYYY` or `±YYYYYY`
*
* @example isoYearString(2024) // "2024"
* @example isoYearString(5) // "0005"
* @example isoYearString(10000) // "+010000"
* @example isoYearString(-5) // "-000005"
*/
export declare function isoYearString(year: number): string;