Skip to content

Commit

Permalink
Add years and “Forever” (1c+) ETAs
Browse files Browse the repository at this point in the history
Sometimes downloads can take a very long time indeed.
  • Loading branch information
da2x authored and devos50 committed Oct 13, 2020
1 parent 263fa96 commit c4ba174
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tribler-gui/tribler_gui/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def pretty_date(time=False):


def duration_to_string(seconds):
years = int(seconds // (60 * 60 * 24 * 365.249))
seconds -= years * (60 * 60 * 24 * 365.249)
weeks = int(seconds // (60 * 60 * 24 * 7))
seconds -= weeks * (60 * 60 * 24 * 7)
days = int(seconds // (60 * 60 * 24))
Expand All @@ -150,6 +152,10 @@ def duration_to_string(seconds):
seconds -= minutes * 60
seconds = int(seconds)

if years >= 100:
return "Forever"
if years > 0:
return "{}y {}w".format(years, weeks)
if weeks > 0:
return "{}w {}d".format(weeks, days)
if days > 0:
Expand Down

0 comments on commit c4ba174

Please sign in to comment.