UNPKG

@burglekitt/gmt

Version:

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

20 lines (19 loc) 824 B
import type { DateTimeUnit } from "../../types/index.js"; /** * Return true when `unit` is a valid DateTimeUnit. * * - Valid units are: "year", "month", "week", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond". * - Accepts any input type and returns false for non-string values. * - Uses type assertion to narrow the type. * * @param unit candidate value of any type * @returns boolean indicating validity * * @example isValidDateTimeUnit("year") // true * @example isValidDateTimeUnit("month") // true * @example isValidDateTimeUnit("weeks") // false * @example isValidDateTimeUnit("invalid") // false * @example isValidDateTimeUnit(123) // false * @example isValidDateTimeUnit(null) // false */ export declare function isValidDateTimeUnit(unit: unknown): unit is DateTimeUnit;