@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
19 lines (18 loc) • 731 B
TypeScript
/**
* Extract the time portion from a UTC datetime string.
*
* - Uses Temporal.Instant.from to parse, converts to specified timezone.
* - Defaults to UTC if no timezone specified.
* - Returns "" for invalid input.
*
* @param value ISO UTC datetime string (e.g., "2024-03-17T14:30:45Z")
* @param options optional: timeZone (IANA)
* @returns ISO time string (e.g., "14:30:45") or "" on invalid input
*
* @example parseTimeFromUtc("2024-03-17T14:30:45Z") // "14:30:45"
* @example parseTimeFromUtc("2024-03-17T14:30:45Z", { timeZone: "America/New_York" }) // "10:30:45"
* @example parseTimeFromUtc("invalid") // ""
*/
export declare function parseTimeFromUtc(value: string, options?: {
timeZone?: string;
}): string;