@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.
16 lines • 782 B
TypeScript
/**
* Return the current year for the specified IANA timeZone.
*
* - Uses nowZonedDateTimeISO() to get the current time.
* - Validation is performed on the timezone.
* - The year is zero-padded to 4 digits. A year outside 0000–9999 is written with a sign and six
* digits (`+010000`, `-000005`), as Temporal writes it at the head of a date.
*
* @param ianaTimezone IANA name or UTC offset: a time zone identifier (`+05:30`, `+0530`, `-08`) or
* a stored offset (`±HH:MM[:SS]`, what `getTimeZoneOffset` returns)
* @returns current year string (zero-padded to 4 digits) or "" on invalid input
*
* @example getZonedYear("Africa/Johannesburg") // "2024"
* @example getZonedYear("invalid") // ""
*/
export declare function getZonedYear(ianaTimezone: string): string;