@thi.ng/date
Version:
Datetime types, relative dates, math, iterators, composable formatters, locales
37 lines • 1.07 kB
TypeScript
/**
* Returns a time formatter for given FPS (frames / second, in `[1,1000]`
* range), e.g. `HH:mm:ss:ff`. The returned function takes a single arg (time in
* milliseconds) and returns formatted string.
*
* @remarks
* The timecode considers days too, but only includes them in the result if the
* day part is non-zero. The 4 separators between each field can be customized
* via 2nd arg (default: all `:`).
*
* @example
* ```ts tangle:../export/timecode.ts
* import { defTimecode, DAY, HOUR, MINUTE, SECOND } from "@thi.ng/date";
*
* const fmt = defTimecode(30);
*
* console.log(
* fmt(HOUR + 2*MINUTE + 3*SECOND + 4*1000/30)
* );
* // "01:02:03:04"
*
* console.log(fmt(DAY));
* // "01:00:00:00:00"
*
* const fmt2 = defTimecode(30, ["d ", "h ", "' ", '" ']);
*
* console.log(
* fmt2(DAY + HOUR + 2 * MINUTE + 3 * SECOND + 999)
* );
* // "01d 01h 02' 03" 29"
* ```
*
* @param fps -
* @param sep -
*/
export declare const defTimecode: (fps: number, sep?: ArrayLike<string>) => (t: number) => string;
//# sourceMappingURL=timecode.d.ts.map