/** * Returns the duration as a string in terms of milliseconds, seconds, minutes, hours, days, months and years. Note that months are considered to be 30 days and years 365 days. * * @example * Basic usage * ```js * // A starting Date somewhere in your code * const startDate = new Date() // or Date.now() * * // When you want to know the elapsed duration, pass the start date * const duration = prettyDuration(startDate) * // Returns something like "22 days, 6 h, 3 min, 15 sec, 3 ms" * * // If you want to console.log it, set the option log to true * prettyDuration(startDate, {log: true}) * * // You can also use a prefix and/or suffix * prettyDuration(startDate, {log: true, prefix: "Total duration: ", suffix: " (Main function)"}) * // Returns and logs something like "Total duration: 3 min, 15 sec, 3 ms (Main function)" * * // If you want to format the duration between two specific dates, use the end option. * prettyDuration(new Date("2024-01-01T17:00:00"), { end: new Date("2024-01-23T23:03:15") }) * // Returns "22 days, 6 h, 3 min, 15 sec, 0 ms" * ``` * * @param start - The start date or timestamp. * @param options - Optional settings. * @param options.log - If true, logs the duration to the console. * @param options.end - The end date or timestamp. * @param options.prefix - A string to prefix the duration with. * @param options.suffix - A string to suffix the duration with. * * @category Formatting */ export default function prettyDuration(start: Date | number, options?: { log?: boolean; end?: Date | number; prefix?: string; suffix?: string; }): string;