UNPKG

@activecollab/components

Version:

ActiveCollab Components

26 lines 1.56 kB
import { FormatType } from "./types"; /** * @function formatHours * @description * Formats a decimal number representing hours into a formatted string (HH:MM) or a short form if needed. * The input can be a number, string, or undefined. It handles various formats and can optionally add a * leading zero to the hours component. With the new "format" argument, if set to "short" and the value is * greater than or equal to 1000, it will return a shortened format (e.g., 1K) similar to formatNumber. * * @param {number | string | undefined} num - The input representing the hours. * @param {boolean} [withLeadingZeroHours=false] - Whether to add a leading zero to the hours part. * @param {boolean} [trimZeroMinutes=false] - Whether to remove minutes if they are zero. * @param {"long" | "short"} [format="long"] - The format type, either "long" for full numbers or "short" for abbreviated output. * * @returns {string} - A formatted time string or a shortened string. * * @example * formatHours(1.5) // "1:30" * formatHours("3.5", true) // "03:30" * formatHours(1500, false, false, "short") // "1K" (using formatNumber) */ export declare const formatHours: (num: number | string | undefined, withLeadingZeroHours?: boolean, trimZeroMinutes?: boolean, format?: FormatType) => string; export declare const withLeadingZero: (num: string | number, size?: number) => string; export declare const isDecimal: (num: number) => boolean; export declare const isValidTime: (time: string | undefined) => boolean; //# sourceMappingURL=timeUtils.d.ts.map