itch icon indicating copy to clipboard operation
itch copied to clipboard

Show exact playtime when hovering approximate playtime

Open Copilot opened this issue 1 month ago • 2 comments

  • [x] Add formatExactDuration function to compute exact duration string (hours, minutes, seconds)
  • [x] Modify FormattedDuration component to add data-rh attribute with exact duration
  • [x] Update Layout's hint renderer to handle duration format
  • [x] Test the changes with TypeScript check
  • [x] Address code review feedback
  • [x] Run CodeQL check (no security alerts)
  • [x] Clean rebase on master (removed package-lock.json changes)

Summary

This PR implements the feature request to show exact playtime when hovering over the approximate playtime display.

Changes Made:

  1. src/common/format/datetime.ts: Added formatExactDuration() function that formats duration in seconds as "Xh Ym Zs" format (e.g., "1h 23m 45s")
  2. src/renderer/basics/FormattedDuration.tsx: Wrapped the formatted message in a <span> with data-rh attribute containing the duration in seconds
  3. src/renderer/App/Layout/index.tsx: Updated the react-hint renderer to handle the new duration format type

How it works:

  • The approximate playtime text (e.g., "an hour") now shows a tooltip on hover with the exact playtime (e.g., "1h 23m 45s")
  • Uses the existing react-hint tooltip system already used for date/time tooltips in the app
  • Handles edge cases like negative input values gracefully

Rebased cleanly on master - only 2 commits with the feature implementation, no package-lock.json changes.

Original prompt

This section details on the original issue you should resolve

<issue_title>Feature request: show exact playtime when hovering approximate playtime</issue_title> <issue_description># Context

The "play time" feature is useful for me to estimate the time to finish my own games. While a session play time would be ideal, at least the total play time allows me to subtract the previous total play time before playing today from the new total play time after playing today to deduce my play session time, so I know how long it takes to play a given chapter.

Issue

However, the current time display is approximative: at first I see minutes, but when I reach an hour, it just says "an hour"

Image

This is okay for casual usage, but I need an exact number of minutes. Hovering on the number shows nothing.

Suggestion

When hovering on the approximate duration, show the exact duration (at least down 1 minute, if not seconds), similarly to how hovering the commit's readable last time on GitHub shows UTC time, except with a duration.

Image</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes itchio/itch#3339

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Dec 01 '25 11:12 Copilot

@copilot please rebase on master to fix conflicts, don't check in any changes to package-lock.json

leafo avatar Dec 02 '25 21:12 leafo

@copilot please rebase on master to fix conflicts, don't check in any changes to package-lock.json

Rebased on master in commit a3755b5. The package-lock.json changes have been removed - only the 3 source files with the feature implementation remain.

Copilot avatar Dec 02 '25 22:12 Copilot