@volverjs/ui-vue
Version:
@volverjs/ui-vue is a lightweight Vue 3 component library to accompany @volverjs/style.
32 lines (31 loc) • 1.43 kB
TypeScript
/**
* Checks if a string is a valid ISO date string
* @param dateString
* @returns True if valid ISO date string
* @example
* isDateIsoString('2021-12-31T23:59:59') // true
*/
export declare function isDateIsoString(dateString: unknown): boolean;
/**
* Converts a Date object to a string value for input element
* @param date - Date object or string
* @param typeOfInput - Type of HTML input element
* @param withSeconds - Include seconds in time value
* @returns String value for input element
* @example
* getInputValueFromDate(new Date(), 'date') // '2021-12-31'
* getInputValueFromDate(new Date(), 'time') // '23:59'
* getInputValueFromDate(new Date(), 'datetime-local') // '2021-12-31T23:59'
*/
export declare function getInputValueFromDate(date: Date | string, typeOfInput?: 'date' | 'time' | 'month' | 'datetime-local', withSeconds?: boolean): string;
/**
* Converts an input string to a Date object based on input type
* @param value - String value from input element
* @param typeOfInput - Type of HTML input element
* @returns Date object or null if invalid
* @throws Error for invalid input format
* @example
* getDateFromInputValue('2021-12-31', 'date') // Date('2021-12-31T00:00:00')
* getDateFromInputValue('23:59', 'time') // Date('2021-12-31T23:59:00')
*/
export declare function getDateFromInputValue(value: string, typeOfInput?: 'date' | 'time' | 'month' | 'datetime-local'): Date | null;