15 lines
495 B
TypeScript
15 lines
495 B
TypeScript
import moment from "moment";
|
|
|
|
export function now(): number {
|
|
return (performance.now() + performance.timeOrigin) / 1000;
|
|
}
|
|
|
|
export function formatTime(time: number, format: 'full' | 'short' = 'full'): string {
|
|
if (format === 'short')
|
|
return moment.utc(time * 1000).format('HH:mm:ss.SSS');
|
|
else
|
|
return moment.utc(time * 1000).format('HH:mm:ss');
|
|
// return moment.utc(time * 1000).format('HH:mm:ss.SSS');
|
|
// return durationFormat.format({ seconds: Math.round(time * 1000) });
|
|
}
|