UNPKG

@cerberus-design/react

Version:

The Cerberus Design React component library.

62 lines (61 loc) 1.8 kB
import { InputHTMLAttributes } from 'react'; export interface UseDateBase { /** * The format of the date input */ format?: string; /** * The callback to run when the date input changes */ onChange?: InputHTMLAttributes<HTMLInputElement>['onChange']; } export interface UseDateOptions extends UseDateBase { /** * The initial value of the date input */ initialValue?: string; } export interface UseDateReturn extends UseDateBase { /** * The ISO formatted date string */ ISO: string; /** * The value of the date input */ value: string; } /** * @deprecated use the DatePicker family instead */ export declare function useDate(options?: UseDateOptions): UseDateReturn; /** * Converts a string in US Military format to ISO format. Used within the `useDate` hook. * @param input The string to format * @returns The formatted string in ISO format (YYYY-MM-DD) */ export declare function formatMilitaryToISO(input: string): string; /** * Converts a string to US Military format. Used within the `useDate` hook. * @param input The string to format * @returns The formatted string in US Military format (DD MMM YYYY) */ export declare function formatMilitaryDate(input: string): string; /** * Formats a date string to US Military format. * @param date The date string to format (i.e., '2024-01-01') * @returns The formatted date string in US Military format (DD MMM YYYY) */ export declare function formatISOToMilitary(date: string): string; /** * Date formatting options * @example * ```tsx * const date = new Date() * const formatted = date.format(DateFormats.USMilitary) */ export declare const DateFormats: { readonly ISO: string; readonly USMilitary: string; readonly Months: string[]; };