import type { DateRangeRef, DateTimeFormat, DateTimeRef, DateTimeType, FormatRef } from "./FormDefinition"; import type { defs } from "./FormHost"; import type { PickersLocaleText } from "@mui/x-date-pickers"; import type { Locale } from "date-fns"; /** * Checks if a form element's value is equal to the supplied value. * @param elementValue The current value of a Form Element. * @param newValue A new value for the Form Element. * @returns True if the element's current value and the new value are equal, false otherwise. */ export declare function areValuesEqual(elementValue: defs.Value | undefined, newValue: DateTimeRef | DateRangeRef | undefined | null): boolean; /** * Checks if a given date is valid or not. * @param date The date object to check. */ export declare function isValidDate(date: Date): boolean; /** * Converts a given two-digit year to its four digit string equivalent or pads with leading zero's to make four digit. * Returns undefined if the input is invalid. * @param year The string for the year. */ export declare function tryParseYear(year: string): string | undefined; /** * Converts a given string to a corresponding two digit month. Performs basic validation. * Returns undefined if input is valid. * @param month The string for the month. */ export declare function tryParseMonth(month: string): string | undefined; /** * Converts a given string to a corresponding two digit day. Performs basic validation. * Returns undefined if input is valid. * @param month The string for the day. */ export declare function tryParseDay(day: string): string | undefined; /** * Processes user input and parses it in the current date format if possible. Else returns undefined. * The purpose of this function is to allow maximum leeway to the user. As long as there are three * numeric values in the input, we'll parse it correctly regardless of separator used and regardless * of whether the day/month were entered as 1 or 2 digits or whether year was entered as 2 or 4 digits. * While some basic validation is performed, this function is simply intended to format user input * correctly and should not be relied upon for validation. Note that this function will always return * four digit year and two digit day and month tokens. * @param input The input date text. */ export declare function tryParseDateText(input: string): string | undefined; /** * The smallest value we can use in date components. * * `0001-01-01 00:00:00.000` (Local Time) */ export declare const MinUIDate: Date; /** * The largest value we can use in date components. * * `9999-12-31 23:59:59.999` (Local Time) */ export declare const MaxUIDate: Date; /** * Whether the time should be shown in 12-hour or 24-hour format. */ export declare enum TimeFormat { /** Use the format preferred by the current locale. */ AUTO = "auto", /** Use a 12-hour clock. */ HOURS_12 = "12-hour", /** Use a 24-hour clock. */ HOURS_24 = "24-hour" } export declare function getAmPm(format: FormatRef | undefined): boolean | undefined; /** * Uses the `lowerBound` and `upperBound` properties of the supplied format * to construct dates for the minimum and maximum values to be returned. * @param format The format property from a form element. * @returns The minimum and maximum values as Dates. */ export declare function getDateBounds(format: FormatRef | undefined): { min: Date; max: Date; }; /** * Retrieves the DateFns locale corresponding to the specified language. This function will return undefined * if the locale is not found. * If the specified language is region specific eg. 'de-AT', this function will first try to retrieve it. In * the event of failure, it will also try to retrieve the generic locale for the given language i.e. 'de' for the * current example. * @param language The target language to retrieve the locale for. */ export declare function getDateFnsLocale(language: string): Promise; export declare function getMuiLocaleText(language: string): Promise> | undefined>; /** * Gets the date format based on the current browser locale. This function will always return four digit year tokens * and two digit month and day tokens. The browser locale however, will determine their placement and the separator. */ export declare function getLocaleDateFormat(): string; export declare function getLocaleDateFormatSeparator(): string; /** * Returns the position of the year, month or day in the date format. eg. 2 for year position in mm/dd/yyyy * 1 for year position in mm/yyyy/dd and 0 for year position in yyyy/mm/dd. */ export declare function getLocaleDateFormatTokenPosition(token: "yyyy" | "dd" | "MM"): number; /** * Inputs that can be converted to a DateRangeRef. Requires two values that can be converted into * start and end dates */ type DateRangeLike = (Date | number | string)[] | { endDate: Date | string; startDate: Date | string; }; /** * Attempts to convert user input into a valid DateRangeRef if possible. If arrays of dates, * numbers are provided, the lower value will be used as the startDate irrespective of order defined. If a * dateRangeRef like object is provided with explicit startDate and endDate properties no swapping will be done. * @param value DateRangeLike inputs which could be an array of string, number, Date or a * DateRangeRef like object. * @returns A valid DateRangeRef if possible. Undefined otherwise. */ export declare function convertToDateRangeRef(value: DateRangeLike | undefined): DateRangeRef | undefined; /** * This function is for the sole purpose of facilitating testing. This should not be * used for any other purpose. An incorrect value set here will result in incorrect * behaviour for the duration of the session or until the value is cleared. * @param dateFormat The date format to set in cache. */ export declare function __test__setlocaleDateFormatInCache(dateFormat: string): void; type PartialValue = void | boolean | number | string | { [name: string]: any; format?: PartialValue | void; locale?: string; refValueType?: string; timezone?: string; value?: number; }; export declare function makeProperValue(value: number | string | PartialValue): Date | undefined; export declare function getNewElementValue(date: Date | undefined | null, refValueType: DateTimeType, format: DateTimeFormat): DateTimeRef | undefined; export {};