import { isDateValid , isDayInRange } from "./common/dateUtils" ; import { IDatePickerBaseProps } from "./datePickerCore" ; export type DateFormatProps = IDateFormatProps ; deprecated export interface IDateFormatProps { default invalidDateMessage ? : string ; /**
     * The locale name, which is passed to `formatDate`, `parseDate`, and the functions in `localeUtils`.
     */ locale ? : string ; default outOfRangeMessage ? : string ; /**
     * Placeholder text to display in empty input fields.
     * Recommended practice is to indicate the expected date format.
     */ placeholder ? : string ; /**
     * Function to render a JavaScript `Date` to a string.
     * Optional `locale` argument comes directly from the prop on this component:
     * if the prop is defined, then the argument will be too.
     */ formatDate ( date , locale ? ) : string ; /**
     * Function to deserialize user input text to a JavaScript `Date` object.
     * Return `false` if the string is an invalid date.
     * Return `null` to represent the absence of a date.
     * Optional `locale` argument comes directly from the prop on this component.
     */ parseDate ( str , locale ? ) : Date | false | null ; } export function getFormattedDateString ( date , props , ignoreRange = false ) { if ( date == null ) { return "" ; } else if ( ! isDateValid ( date ) ) { return props . invalidDateMessage ; } else if ( ignoreRange || isDayInRange ( date , [ props . minDate , props . maxDate ] ) ) { return props . formatDate ( date , props . locale ) ; } else { return props . outOfRangeMessage ; } }