Something went wrong. Try again.
fossabot clone for streamplace superbot.mmatt.net
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960/** Human durations like "2 hours, 5 minutes" or "3 years, 2 months and 4 days". */export function formatDuration(ms: number, maxParts = 3): string { let s = Math.max(0, Math.floor(ms / 1000)) const units: [string, number][] = [ ['year', 365 * 86400], ['month', 30 * 86400], ['day', 86400], ['hour', 3600], ['minute', 60], ['second', 1], ] const parts: string[] = [] for (const [name, size] of units) { if (s >= size) { const n = Math.floor(s / size) s -= n * size parts.push(`${n} ${name}${n === 1 ? '' : 's'}`) } if (parts.length >= maxParts) break } if (parts.length === 0) return '0 seconds' if (parts.length === 1) return parts[0] return `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`}
/** Compact durations like "5m", "2h", "3d" for lists. */export function shortDuration(ms: number): string { const s = Math.max(0, Math.floor(ms / 1000)) if (s < 60) return `${s}s` if (s < 3600) return `${Math.floor(s / 60)}m` if (s < 86400) return `${Math.floor(s / 3600)}h` if (s < 86400 * 7) return `${Math.floor(s / 86400)}d` if (s < 86400 * 30) return `${Math.floor(s / (86400 * 7))}w` if (s < 86400 * 365) return `${Math.floor(s / (86400 * 30))}mo` return `${Math.floor(s / (86400 * 365))}y`}
/** Seconds as "90s", "5m", "1h 30m" for timeouts. */export function formatSeconds(total: number): string { if (total < 60) return `${total}s` const h = Math.floor(total / 3600) const m = Math.floor((total % 3600) / 60) const s = total % 60 return [h ? `${h}h` : '', m ? `${m}m` : '', s && !h ? `${s}s` : ''].filter(Boolean).join(' ')}
export const ACTIVITY_LABELS: Record<string, string> = { just_chatting: 'Just Chatting', events: 'Events', podcasting: 'Podcasting', music: 'Music', art: 'Art', software_dev: 'Software Development', cooking: 'Cooking', miniatures: 'Miniatures', makers_crafting: 'Makers & Crafting', fitness: 'Fitness', sports: 'Sports',}