@thi.ng/date
Version:
Datetime types, relative dates, math, iterators, composable formatters, locales
23 lines (22 loc) • 483 B
JavaScript
import { Z2 } from "@thi.ng/strings/pad-left";
import { decomposeDuration } from "./duration.js";
const defTimecode = (fps, sep = "::::") => {
const frame = 1e3 / fps;
return (t) => {
const [_, __, d, h, m, s, ms] = decomposeDuration(t);
const parts = [
Z2(h),
sep[1],
Z2(m),
sep[2],
Z2(s),
sep[3],
Z2(ms / frame | 0)
];
d > 0 && parts.unshift(Z2(d), sep[0]);
return parts.join("");
};
};
export {
defTimecode
};