@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
21 lines (20 loc) • 829 B
TypeScript
import { type UnixUnit } from "../validate/index.js";
/**
* Extract the time portion from a unix epoch value.
*
* - Converts to ZonedDateTime then extracts the PlainTime.
* - Uses system timezone if not specified.
* - Returns "" for invalid input.
*
* @param value unix epoch in milliseconds or seconds (number)
* @param options optional: epochUnit ("seconds" | "milliseconds"), timeZone (IANA)
* @returns ISO time string (e.g., "14:30:45") or "" on invalid input
*
* @example parseTimeFromUnix(1700000000000) // "04:13:20"
* @example parseTimeFromUnix(1700000000, { epochUnit: "seconds" }) // "04:13:20"
* @example parseTimeFromUnix(-86400, { epochUnit: "seconds" }) // "00:00:00"
*/
export declare function parseTimeFromUnix(value: number, options?: {
epochUnit?: UnixUnit;
timeZone?: string;
}): string;