import { MaskParser } from '../mask-input/mask-parser.js'; import { createDatePart, DatePartType, type IDatePart } from './date-part.js'; /** * Types of date/time parts that can appear in a format string. * Re-exported from date-part.ts for backward compatibility. */ export { DatePartType as DateParts }; /** * Re-export createDatePart factory for creating standalone parts. */ export { createDatePart }; /** * Information about a parsed date part within a format string. * This is a type alias for IDatePart for backward compatibility. */ export type DatePartInfo = IDatePart; /** Options for the DateTimeMaskParser */ export interface DateTimeMaskOptions { /** The date/time format string (e.g., 'MM/dd/yyyy', 'HH:mm:ss') */ format?: string; /** The prompt character for unfilled positions */ promptCharacter?: string; } /** * A specialized mask parser for date/time input fields. * Extends MaskParser to handle date-specific format patterns and validation. * * @example * ```ts * const parser = new DateTimeMaskParser({ format: 'MM/dd/yyyy' }); * parser.apply('12252023'); // Returns '12/25/2023' * parser.parseDate('12/25/2023'); // Returns Date object * ``` */ export declare class DateTimeMaskParser extends MaskParser { /** Parsed date parts from the format string */ private _dateParts; /** * Gets the parsed date parts from the format string. * Each part contains type, position, and format information. */ get dateParts(): ReadonlyArray; constructor(options?: DateTimeMaskOptions); /** * Sets a new date/time format and re-parses the date parts. */ set mask(value: string); get mask(): string; /** * Parses the format string into IDatePart objects. * This identifies each date/time component and its position. */ private _parseDateFormat; /** * Normalizes year format to 'yyyy' for editing (except for 'yy'). * Also updates the end position to account for the expanded format. */ private _normalizeYearFormatBuilder; /** * Parses a masked string into a Date object. * Returns null if the string cannot be parsed into a valid date. * * @param masked - The masked input string to parse * @returns A Date object or null if parsing fails */ parseDate(masked: string): Date | null; /** * Extracts numeric values from the masked string for each date part. */ private _extractDateValues; /** * Validates that parsed date parts are within valid ranges. * Only validates parts that are present in the format. * Uses the validate() method on each date part instance. */ private _validateDateParts; /** * Applies AM/PM conversion to hours if format includes AM/PM. */ private _applyAmPmConversion; /** * Creates a Date object from parsed parts with defaults for missing values. */ private _createDateFromParts; /** * Gets the number of days in a specific month/year. */ private _daysInMonth; /** * Formats a Date object into a masked string according to the current format. * * @param date - The date to format * @returns The formatted masked string */ formatDate(date: Date | null): string; /** * Finds the date part at a given cursor position. * Uses exclusive end (position < end) for precise character targeting. * * @param position - The cursor position to check * @returns The DatePartInfo at that position, or undefined if not found */ getDatePartAtPosition(position: number): DatePartInfo | undefined; /** * Finds the date part for a cursor position, using inclusive end. * This handles the edge case where cursor is at the end of the mask * (position equals the end of the last part). * * @param position - The cursor position to check * @returns The DatePartInfo at that position, or undefined if not found */ getDatePartForCursor(position: number): DatePartInfo | undefined; /** * Checks if the format includes any date parts (day, month, year). */ hasDateParts(): boolean; /** * Checks if the format includes any time parts (hours, minutes, seconds). */ hasTimeParts(): boolean; /** * Gets the first non-literal date part (useful for default selection). */ getFirstDatePart(): DatePartInfo | undefined; /** * Gets a specific type of date part. */ getPartByType(type: DatePartType): DatePartInfo | undefined; /** * Builds the internal mask pattern from the date format. * Converts date format characters to mask pattern characters. */ protected _parseMaskLiterals(): void; /** * Converts a date format string to a mask format string. * Date format chars become '0' (numeric) or 'L' (alpha for AM/PM). */ private _convertToMaskFormat; }