blanchon's picture
Rich data table on home page, interactive bigger minimap, tactical-reveal player swap
91677d6
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, ' ');
}