fix: add 'years' and 'Infinity' to ETA in transmission-remote (#5584)

This commit is contained in:
lvd2 2023-06-20 20:29:57 +03:00 committed by GitHub
parent 280dea4e33
commit d0b0810457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 4 deletions

View File

@ -118,7 +118,22 @@ static std::string etaToString(int64_t eta)
return fmt::format(FMT_STRING("{:d} hrs"), eta / (60 * 60));
}
return fmt::format(FMT_STRING("{:d} days"), eta / (60 * 60 * 24));
if (eta < (60 * 60 * 24 * 30))
{
return fmt::format(FMT_STRING("{:d} days"), eta / (60 * 60 * 24));
}
if (eta < (60 * 60 * 24 * 30 * 12))
{
return fmt::format(FMT_STRING("{:d} months"), eta / (60 * 60 * 24 * 30));
}
if (eta < (60 * 60 * 24 * 365 * 1000LL)) // up to 999 years
{
return fmt::format(FMT_STRING("{:d} years"), eta / (60 * 60 * 24 * 365));
}
return "";
}
static std::string tr_strltime(time_t seconds)
@ -1444,7 +1459,7 @@ static void printTorrentList(tr_variant* top)
double total_down = 0;
printf(
"%6s %-4s %9s %-8s %6s %6s %-5s %-11s %s\n",
"%6s %-4s %9s %-9s %6s %6s %-5s %-11s %s\n",
"ID",
"Done",
"Have",
@ -1484,7 +1499,7 @@ static void printTorrentList(tr_variant* top)
std::string{ "n/a" };
fmt::print(
FMT_STRING("{:6d}{:c} {:>4s} {:>9s} {:<8s} {:6.1f} {:6.1f} {:>5s} {:<11s} {:s}\n"),
FMT_STRING("{:6d}{:c} {:>4s} {:>9s} {:<9s} {:6.1f} {:6.1f} {:>5s} {:<11s} {:s}\n"),
torId,
error_mark,
done_str,
@ -1503,7 +1518,7 @@ static void printTorrentList(tr_variant* top)
}
fmt::print(
FMT_STRING("Sum: {:>9s} {:6.1f} {:6.1f}\n"),
FMT_STRING("Sum: {:>9s} {:6.1f} {:6.1f}\n"),
strlsize(total_size).c_str(),
total_up / static_cast<double>(tr_speed_K),
total_down / static_cast<double>(tr_speed_K));