@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 • 828 B
TypeScript
/**
* Format a non-negative count of nanoseconds as an ISO 8601 duration with hours as the largest
* unit — the string `Temporal.Instant.prototype.until(…, { largestUnit: "hour" }).toString()`
* produces for a span of that length. Returns "" for a negative count or if Temporal throws.
*
* - Splits with bigint division, so it stays exact past 2^53 ns and across the full Instant
* span (1.728 × 10^22 ns = 4 800 000 000 h, which `Number` holds exactly).
*
* @param nanoseconds non-negative elapsed nanoseconds
* @returns ISO 8601 duration string, or "" on invalid input
*
* @example formatHourDuration(0n) // "PT0S"
* @example formatHourDuration(178200000000001n) // "PT49H30M0.000000001S"
* @example formatHourDuration(-1n) // ""
*/
export declare function formatHourDuration(nanoseconds: bigint): string;