@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.
19 lines • 960 B
TypeScript
/**
* Convert a UTC Instant string to a zoned ISO 8601 datetime string.
*
* - Uses Temporal.Instant.from to parse, converts to specified timezone.
* - Validates both UTC input and timezone.
* - Returns "" for invalid input.
* - An offset with seconds (`-00:44:30`) returns `""`. A written zone cannot carry seconds (RFC
* 9557 §4.1), so the result could not name it. Pass the IANA name, or call
* `fromOffsetInstant({ instant, offset })` for the local time with its full offset and no
* bracket.
*
* @param value UTC Instant string
* @param timeZone IANA name or a UTC offset to the minute (what `isValidTimeZone` accepts)
* @returns zoned ISO 8601 string or "" on invalid
*
* @example convertUtcToZoned("2024-02-29T00:00:00Z", "Australia/Sydney") // "2024-02-29T11:00:00+11:00[Australia/Sydney]"
* @example convertUtcToZoned("invalid", "UTC") // ""
*/
export declare function convertUtcToZoned(value: string, timeZone: string): string;