@redkhat/timepicker
Version:
This project contains a series of time selection components. The timepicker allows users to select a time from a clock-like interface. The timepicker is built using **Angular 19+** and **Angular Material 19+**.
28 lines (27 loc) • 1.37 kB
TypeScript
export declare function secondsToDate(seconds: number): Date;
export declare function detectTimeFormat(date: Date): string;
export declare function splitDate(date: Date): SimpleTime;
export declare function amPmTransform(isAm: string, date: Date): Date;
export declare function validateTimeValue(value: string, max: number): string;
export declare function formatTimeValue(value: string, defaultValue: string, padLength?: number): string;
export interface SimpleTime {
hours: number;
minutes: number;
}
/**
* Converts a time string or number to the number of seconds since midnight.
*
* Supported formats include:
* - Integers (e.g., "10", "1030", 10, 1030) in 24-hour format (up to 2359).
* - Space-separated numbers (e.g., "10 30") as HH MM.
* - Colon-separated numbers (e.g., "10:30" or "10:30:00") as HH:MM or HH:MM:SS.
* - Formats with regional AM/PM markers either at the beginning or at the end
* (e.g., "10:30am", "am 10:30", "午後3:25:00", "10:30 du matin").
*
* Additionally, this function normalizes Arabic digits (Unicode range \u0660-\u0669)
* to their Western counterparts before processing.
*
* @param input The input to convert (can be a string or number).
* @returns The number of seconds since midnight, or null if the input is invalid.
*/
export declare function timeToSecondsi18n(input: string | number): number | null;