@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
21 lines (20 loc) • 837 B
TypeScript
import { type UnixUnit } from "../validate/index.js";
/**
* Extract the date portion from a unix epoch value.
*
* - Converts to ZonedDateTime then extracts the PlainDate.
* - 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 date string (e.g., "2024-03-17") or "" on invalid input
*
* @example parseDateFromUnix(1700000000000) // "2023-11-15"
* @example parseDateFromUnix(1700000000, { epochUnit: "seconds" }) // "2023-11-15"
* @example parseDateFromUnix(-86400, { epochUnit: "seconds" }) // "1969-12-31"
*/
export declare function parseDateFromUnix(value: number, options?: {
epochUnit?: UnixUnit;
timeZone?: string;
}): string;