UNPKG

@burglekitt/gmt

Version:

Temporal-based date and time utilities with timezone support and polyfill integration

19 lines (18 loc) 786 B
import type { DateTimeUnit } from "../../types/index.js"; type UnixNowUnit = DateTimeUnit | "dayOfWeek"; /** * Return the requested unit value from the current Unix timestamp in UTC. * * - Valid units: "year", "month", "week", "day", "dayOfWeek", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond". * - Uses Temporal.Now.instant() converted to UTC zoned date time. * - Returns "" on invalid unit or failure. * * @param unit unit to extract from current unix timestamp * @returns string representation of the requested unit or "" on invalid * * @example getUnixNowUnit("year") // "2024" * @example getUnixNowUnit("month") // "02" * @example getUnixNowUnit("invalid") // "" */ export declare function getUnixNowUnit(unit: UnixNowUnit): string; export {};