@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
20 lines (19 loc) • 770 B
TypeScript
import type { UnixUnit } from "../validate/index.js";
/**
* Return the year from a unix epoch value.
*
* - Delegates to {@link parseUnitFromUnix} with unit "year".
* - Returns "" for invalid input.
*
* @param value unix epoch in milliseconds or seconds (number or string)
* @param options optional: epochUnit ("seconds" | "milliseconds"), timeZone (IANA)
* @returns Year (YYYY) or "" on invalid input
*
* @example parseYearFromUnix(1700000000000) // "2023"
* @example parseYearFromUnix(1704067200000, { epochUnit: "milliseconds" }) // "2024"
* @example parseYearFromUnix(-86400, { epochUnit: "seconds" }) // "1969"
*/
export declare function parseYearFromUnix(value: number | string, options?: {
epochUnit?: UnixUnit;
timeZone?: string;
}): string;