Skip to content

Consolidate duplicated clock-time formatting helpers in the web app #65

Description

@RobinEdquist

The H:MM:SS clock-time formatter is copy-pasted in at least five places in apps/web, with slightly diverging details (one copy lacks the isFinite guard):

  • components/player/player-bar.tsxformatTime()
  • components/player/chapter-drawer.tsxformatDuration() (identical copy)
  • app/(authenticated)/audiobooks/[id]/page.tsxformatChapterTime() (no isFinite guard)
  • components/users/session-log.tsxformatPosition() + formatSessionDuration()

The shared lib/format-duration.ts only covers humanized durations ("5h 30m"), not clock-style timestamps.

The bookmarks feature (#64) introduces a shared apps/web/lib/format-timestamp.ts with formatTimestamp(seconds) (and parseTimestamp() for input). Once that lands:

Task: migrate the five local copies to the shared formatTimestamp() util and delete the local helpers. Behavior should stay identical (H:MM:SS above one hour, M:SS below, "0:00" fallback for non-finite input).

Acceptance criteria:

  • No local clock-time formatters remain in the files listed above
  • All call sites use lib/format-timestamp.ts
  • Existing unit tests pass; format-timestamp tests cover the fallback cases the local copies handled

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions