opendash
Version:
open.DASH data visualization framework
15 lines • 567 B
JavaScript
import { intlSelectUnit } from "..";
// @ts-ignore // TODO
var rtf = Intl.RelativeTimeFormat ? new Intl.RelativeTimeFormat() : null;
export function formatRelativeDates(from, to) {
if (to === void 0) { to = Date.now(); }
if (!from) {
console.warn("formatRelativeDates requires a 'from' parameter");
return "-";
}
if (!rtf) {
return Math.round(Math.abs(from.valueOf() - to.valueOf()) / 1000) + "s";
}
return rtf.format.apply(rtf, intlSelectUnit(from, to));
}
//# sourceMappingURL=formatRelativeDates.js.map