Skip to the content

Capsid menu

app/lib/podcast/clock.mjs

14 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of clock.mjs
FunctionLinesComplexityCoveredCRAPMutation
clockTime9 to 153100%OkCRAP 3No data: no mutants in this code

Imports

It imports no other module of this repo. Imported by app/components/home-podcast.tsx, app/enhance/podcast.ts.

Source

// On its own, without the feed parser, because the player's enhancement bundle imports it.

/**
 * A duration as a clock: `m:ss`, or `h:mm:ss` from an hour. A missing or unreadable length (NaN,
 * which an audio element reports before its metadata loads) reads as 0:00.
 *
 * @param {number} seconds
 */
export function clockTime(seconds) {
  const s = Math.max(0, Math.floor(seconds || 0));
  const h = Math.floor(s / 3600);
  const m = Math.floor((s % 3600) / 60);
  const rest = String(s % 60).padStart(2, "0");
  return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${rest}` : `${m}:${rest}`;
}