Spaces:
Running
Running
File size: 1,335 Bytes
31d3580 91677d6 31d3580 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | export function formatDate(iso: string): string {
if (!iso) return '';
const d = new Date(iso);
return d.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
}
export function formatDateTime(iso: string): string {
if (!iso) return '';
const d = new Date(iso);
return d.toLocaleString(undefined, {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
}
export function formatDuration(seconds: number): string {
if (!Number.isFinite(seconds) || seconds < 0) return '0:00';
const total = Math.round(seconds);
const m = Math.floor(total / 60);
const s = total % 60;
return `${m}:${s.toString().padStart(2, '0')}`;
}
export function formatLongDuration(seconds: number): string {
if (!Number.isFinite(seconds) || seconds <= 0) return '—';
const total = Math.round(seconds);
const h = Math.floor(total / 3600);
const m = Math.floor((total % 3600) / 60);
const s = total % 60;
if (h > 0) return `${h}:${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
return `${m}:${s.toString().padStart(2, '0')}`;
}
export function ticksToSeconds(ticks: number, tickRate = 64): number {
return ticks / tickRate;
}
export function prettyMap(map: string): string {
return map.replace(/^de_/, '').replace(/^cs_/, '').replace(/_/g, ' ');
}
|