feat(frontend): dashboard and stats pages
This commit is contained in:
12
packages/frontend/src/lib/format.ts
Normal file
12
packages/frontend/src/lib/format.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user