Show exact playtime when hovering approximate playtime
- [x] Add
formatExactDurationfunction to compute exact duration string (hours, minutes, seconds) - [x] Modify
FormattedDurationcomponent to adddata-rhattribute 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:
src/common/format/datetime.ts: AddedformatExactDuration()function that formats duration in seconds as "Xh Ym Zs" format (e.g., "1h 23m 45s")src/renderer/basics/FormattedDuration.tsx: Wrapped the formatted message in a<span>withdata-rhattribute containing the duration in secondssrc/renderer/App/Layout/index.tsx: Updated the react-hint renderer to handle the newdurationformat 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"
![]()
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.
</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 please rebase on master to fix conflicts, don't check in any changes to package-lock.json
@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.