Skip to content

Change playtime formatting to use total hours - #4884

Merged
mirkobrombin merged 2 commits into
bottlesdevs:mainfrom
hopsayer:count-playtime-in-hours
Oct 27, 2026
Merged

mirkobrombin merged 2 commits into
bottlesdevs:mainfrom
hopsayer:count-playtime-in-hours

Conversation

@hopsayer

@hopsayer hopsayer commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Note

CI fails on actions/checkout due to the missing submodule URL — this looks pre-existing and unrelated to my changes.

Closes: #4883

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Description

This PR updates the playtime formatting to use total accumulated hours instead of days.

Previously, playtime over 24 hours was shown as 2d 00h. Now it is shown as 48h 00m. Minutes are always displayed, even when zero (e.g., 5h 00m).

Motivation

Day-based formatting is uncommon and unintuitive for playtime tracking in gaming platforms. Using total hours is more intuitive and matches the standard set by platforms like Steam.

And this situation is possible, which gets a user confused:

image

Days are easily mixed up with hours.

Changes

  • Modified format_playtime in bottles/frontend/utils/playtime.py.

Testing

  • Built app. Ran app. App behaves usually. Closed.
  • Populated with a runner and games. Modified games' playtimes with sqlite3 process_metrics.sqlite so they show representative values and demostrate everything works.
  • Verified with existing playtime records that 48h 00m is displayed instead of 2d 00h.
  • Verified that minutes are no longer truncated for whole hours (e.g., 5h 00m).
  • Verified that "View playtime statistics" window for any game continues working correctly.

Before/After

After:

image
Before: image
"View playtime statistics" window image

Generative AI assistance

AI assistance: trivial

Previously, playtime exceeding 24 hours was formatted as days and hours (e.g., 2d 00h).
This changes the formatting to use total accumulated hours (e.g., 48h 00m), which is more standard and intuitive for playtime tracking.
Minutes are now always displayed, even when zero, to maintain consistency.

@mirkobrombin mirkobrombin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The total-hours format is fine. Please update test_format_playtime in bottles/tests/frontend/test_playtime_service.py, which still expects 1d/2d output, and the format_playtime docstring examples. The changed behavior should pass the existing suite with the new expectations.

@hopsayer

Copy link
Copy Markdown
Contributor Author

Updated test_format_playtime expectations to 24h 00m / 25h 00m / 50h 00m, and added 24h 01m / 50h 02m cases to match equivalent existing lines for minutes and as a guard against days-format regression. Refreshed the format_playtime docstring to reflect the total-hours format (>= 3600s: "Hh MMm", no days). All 5 tests in test_playtime_service.py pass. Ready for re-review.

Checked why CI is not passing and it seems unrelated to my changes.

@mirkobrombin mirkobrombin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests and docstring now match the total-hours format. All five playtime frontend tests pass.

@mirkobrombin
mirkobrombin merged commit 8856210 into bottlesdevs:main Oct 27, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Improve playtime formatting to use total hours instead of days

2 participants