[frontend] use hh:mm:ss for playtime so we don't have to translate h,m or s suffixes (#3065)

Signed-off-by: lizzie lizzie@eden-emu.dev
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3065
Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-11-21 19:28:26 +01:00 committed by crueter
parent 61f3ce643c
commit 73713737c6
No known key found for this signature in database
GPG Key ID: 425ACD2D4830EBC6
1 changed files with 3 additions and 19 deletions

View File

@ -167,25 +167,9 @@ void PlayTimeManager::ResetProgramPlayTime(u64 program_id) {
Save(); Save();
} }
std::string PlayTimeManager::GetReadablePlayTime(u64 time_seconds) { std::string PlayTimeManager::GetReadablePlayTime(u64 t) {
if (time_seconds == 0) { return t > 0 ? fmt::format("{:02}:{:02}:{:02}", t / 3600, (t / 60) % 60, t % 60)
return {}; : std::string{};
}
const auto time_minutes = std::max(static_cast<double>(time_seconds) / 60.0, 1.0);
const auto time_hours = static_cast<double>(time_seconds) / 3600.0;
const bool is_minutes = time_minutes < 60.0;
if (is_minutes) {
return fmt::format("{:.0f} m", time_minutes);
} else {
const bool has_remainder = time_seconds % 60 != 0;
if (has_remainder) {
return fmt::format("{:.1f} h", time_hours);
} else {
return fmt::format("{:.0f} h", time_hours);
}
}
} }
std::string PlayTimeManager::GetPlayTimeHours(u64 time_seconds) { std::string PlayTimeManager::GetPlayTimeHours(u64 time_seconds) {