@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
19 lines (18 loc) • 751 B
TypeScript
import type { DateTimeUnit } from "../../types/index.js";
type UtcNowUnit = DateTimeUnit | "dayOfWeek";
/**
* Return the requested unit value from the current UTC instant.
*
* - Valid units: "year", "month", "week", "day", "dayOfWeek", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond".
* - Uses Temporal.Now.instant() converted to UTC.
* - Returns "" on invalid unit or failure.
*
* @param unit unit to extract from current utc instant
* @returns string representation of the requested unit or "" on invalid
*
* @example getUtcNowUnit("year") // "2024"
* @example getUtcNowUnit("month") // "02"
* @example getUtcNowUnit("invalid") // ""
*/
export declare function getUtcNowUnit(unit: UtcNowUnit): string;
export {};