UNPKG

@storm-stack/date-time

Version:

This package includes a DateTime class, various utility functions for working with dates and times, and a number of formatting options.

37 lines (36 loc) 1.05 kB
import { DateInput, type Format } from "@formkit/tempo"; import type { Temporal } from "@js-temporal/polyfill"; export type FormatTimeOptions = Partial<Temporal.ToStringPrecisionOptions> & { /** * Should an empty string be returned if the date is null or undefined * * @defaultValue false */ returnEmptyIfNotSet?: boolean; /** * Should an empty string be returned if the date is invalid * * @defaultValue false */ returnEmptyIfInvalid?: boolean; /** * The format to use when generating the string * * @remarks * For more information read the [Tempo documentation](https://tempo.formkit.com/#format-tokens) * * @defaultValue "h:mm A" */ format?: Format; /** * The locale used in the formatting */ locale?: string; }; /** * Format a time field * * @param dateTime - The date time to format * @returns The formatted time string */ export declare const formatTime: (dateTime?: DateInput | null, options?: FormatTimeOptions) => string;