UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

19 lines • 860 B
import { DateDurationUnit } from "../../types/date-duration-unit.js"; import "../../types/index.js"; /** * Return true when `unit` is a valid DateDurationUnit. * * - Valid units are: "years", "months", "weeks", "days". * - A value that is not a string, a `String` object included, returns `false`. A `true` result * narrows the value to the unit type. * * @param unit any value; a string is checked against the date duration units * @returns boolean indicating whether the unit is valid * * @example isValidDateDurationUnit("days") // true * @example isValidDateDurationUnit("months") // true * @example isValidDateDurationUnit("years") // true * @example isValidDateDurationUnit("invalid") // false * @example isValidDateDurationUnit(null) // false */ export declare const isValidDateDurationUnit: (unit: unknown) => unit is DateDurationUnit;