/** * Time segment */ type Segment = { hours: number; minutes: number; seconds: number; milliseconds: number; }; /** * Time format: * - HH:mm (e.g. 00:00, 23:59) * - HH:mm:ss (e.g. 00:00:00, 23:59:59) * - HH:mm:ss.SSS (e.g. 00:00:00.000, 23:59:59.000) */ declare enum Format { /** * HH:mm (e.g. 00:00, 23:59) */ HHmm = "HH:mm", /** * HH:mm:ss (e.g. 00:00:00, 23:59:59) */ HHmmss = "HH:mm:ss", /** * HH:mm:ss.SSS (e.g. 00:00:00.000, 23:59:59.000) */ HHmmssSSS = "HH:mm:ss.SSS" } type InputFormat = Format | keyof typeof Format; /** * Try to guess time format * @param value Value to test * @returns format Time format or undefined */ declare const getFormat: (value: string) => Format | null; /** * Check if passed value is a valid time string. * For instance: 10:00, 23:59:59, 23:59:59.000 * @param value Value to check * @param [format] The format to validate value against. If not defined, try to guess the format * @returns value is valid. */ declare const isValid: (value: string, format?: InputFormat | null) => boolean; /** * Get Local/UTC values segments of Date object or value string * @param value Valid date or a string in a format 10:00, 23:59:59 or 23:59:59.999 * @param [isUTC=false] True to get UTC values, false to get Local values * @returns Segment */ declare const toSegment: (value: string | Date, isUTC?: boolean) => Segment; /** * Format Date or Segment to Local Time string. * @param value A valid Date or Segment * @param [format='HH:mm'] Time format, one of 'HH:mm' | 'HH:mm:ss' | 'HH:mm:ss.SSS' * @returns A formatted time */ declare const format: (value: Segment | Date, format?: InputFormat) => string; /** * Format Date or Segment to UTC Time string. * @param value A valid Date or Segment * @param [format='HH:mm'] Time format, one of 'HH:mm' | 'HH:mm:ss' | 'HH:mm:ss.SSS' * @returns A formatted time */ declare const utcFormat: (value: Segment | Date, format?: InputFormat) => string; /** * Get Local Date object from value string or Segment. * @param value Value to parse, Segment or 'HH:mm' | 'HH:mm:ss' | 'HH:mm:ss.SSS' * @returns parsed date or invalid date */ declare const parse: (value: string | Segment) => Date; /** * Get UTC Date object from value string or Segment. * @param value Value to parse, Segment or 'HH:mm' | 'HH:mm:ss' | 'HH:mm:ss.SSS' * @returns parsed date or invalid date */ declare const utcParse: (value: string | Segment) => Date; /** * Add offset in milliseconds to the value * @param value the time * @param amount number of milliseconds to add * @returns new value */ declare const addOffset: (value: string, amount: number) => string; /** * Subtract offset in milliseconds from the value * @param value the time * @param amount number of milliseconds to subtract * @returns new value */ declare const subOffset: (value: string, amount: number) => string; export { Segment, Format, InputFormat, isValid, toSegment, format, utcFormat, addOffset, subOffset, getFormat, parse, utcParse };