13 lines
452 B
TypeScript
13 lines
452 B
TypeScript
export function formatDuration(seconds: number): string {
|
|
const h = Math.floor(seconds / 3600);
|
|
const m = Math.floor((seconds % 3600) / 60);
|
|
const s = seconds % 60;
|
|
if (h > 0) return `${h}u ${m}m`;
|
|
if (m > 0) return `${m}m ${s}s`;
|
|
return `${s}s`;
|
|
}
|
|
export function formatPct(n: number): string { return `${Math.round(n * 100)}%`; }
|
|
export function formatDate(unixSec: number): string {
|
|
return new Date(unixSec * 1000).toLocaleString();
|
|
}
|