| 1225 | } |
| 1226 | |
| 1227 | std::string GameList::FormatTimespan(const std::time_t timespan, const bool long_format) |
| 1228 | { |
| 1229 | const u32 hours = static_cast<u32>(timespan / 3600); |
| 1230 | const u32 minutes = static_cast<u32>((timespan % 3600) / 60); |
| 1231 | const u32 seconds = static_cast<u32>((timespan % 3600) % 60); |
| 1232 | |
| 1233 | std::string ret; |
| 1234 | if (!long_format) |
| 1235 | { |
| 1236 | if (hours >= 100) |
| 1237 | ret = fmt::format(TRANSLATE_FS("GameList", "{}h {}m"), hours, minutes); |
| 1238 | else if (hours > 0) |
| 1239 | ret = fmt::format(TRANSLATE_FS("GameList", "{}h {}m {}s"), hours, minutes, seconds); |
| 1240 | else if (minutes > 0) |
| 1241 | ret = fmt::format(TRANSLATE_FS("GameList", "{}m {}s"), minutes, seconds); |
| 1242 | else if (seconds > 0) |
| 1243 | ret = fmt::format(TRANSLATE_FS("GameList", "{}s"), seconds); |
| 1244 | else |
| 1245 | ret = "None"; |
| 1246 | } |
| 1247 | else |
| 1248 | { |
| 1249 | if (hours > 0) |
| 1250 | ret.assign(TRANSLATE_PLURAL_STR("GameList", "%n hours", "", hours)); |
| 1251 | else if (minutes > 0) |
| 1252 | ret.assign(TRANSLATE_PLURAL_STR("GameList", "%n minutes", "", minutes)); |
| 1253 | else |
| 1254 | ret.assign(TRANSLATE_PLURAL_STR("GameList", "%n seconds", "", seconds)); |
| 1255 | } |
| 1256 | |
| 1257 | return ret; |
| 1258 | } |
| 1259 | |
| 1260 | std::string GameList::GetCoverImagePathForEntry(const Entry* entry) |
| 1261 | { |