|
|
|
@ -13,6 +13,9 @@ |
|
|
|
#include "core/hle/service/acc/profile_manager.h"
|
|
|
|
#include "play_time_manager.h"
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
namespace PlayTime { |
|
|
|
|
|
|
|
namespace { |
|
|
|
@ -164,4 +167,37 @@ void PlayTimeManager::ResetProgramPlayTime(u64 program_id) { |
|
|
|
Save(); |
|
|
|
} |
|
|
|
|
|
|
|
std::string PlayTimeManager::GetReadablePlayTime(u64 time_seconds) { |
|
|
|
if (time_seconds == 0) { |
|
|
|
return {}; |
|
|
|
} |
|
|
|
|
|
|
|
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) { |
|
|
|
return fmt::format("{}", time_seconds / 3600); |
|
|
|
} |
|
|
|
|
|
|
|
std::string PlayTimeManager::GetPlayTimeMinutes(u64 time_seconds) { |
|
|
|
return fmt::format("{}", (time_seconds % 3600) / 60); |
|
|
|
} |
|
|
|
|
|
|
|
std::string PlayTimeManager::GetPlayTimeSeconds(u64 time_seconds) { |
|
|
|
return fmt::format("{}", time_seconds % 60); |
|
|
|
} |
|
|
|
|
|
|
|
} // namespace PlayTime
|