shownUptime

tcmts.cli.running.shownUptime · #mgnkbnoi · term · runs anywhere

How long something has run, briefly: 40s, 12m, 3h, 2d.

export function shownUptime(ms: number): string {
  const s = Math.max(0, Math.round(ms / 1000));
  if (s < 60) return `${s}s`;
  if (s < 3600) return `${Math.floor(s / 60)}m`;
  if (s < 86_400) return `${Math.floor(s / 3600)}h`;
  return `${Math.floor(s / 86_400)}d`;
}

used by