@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.
38 lines (37 loc) • 1.12 kB
TypeScript
import { DateInput, type Format } from "@formkit/tempo";
import type { Temporal } from "@js-temporal/polyfill";
export type FormatDateTimeOptions = Partial<Temporal.ZonedDateTimeToStringOptions> & {
/**
* 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 "M/D/YYYY h:mm A"
*/
format?: Format;
/**
* The locale used in the formatting
*/
locale?: string;
};
/**
* Format a date time field
*
* @param dateTime - The date time to format
* @param options - The options to use
* @returns The formatted date time
*/
export declare const formatDateTime: (dateTime?: DateInput | null, options?: FormatDateTimeOptions) => string;