Skip to content

Commit

Permalink
Merge pull request #1386 from CompactCow/patch-1
Browse files Browse the repository at this point in the history
Fix uptime calculation
  • Loading branch information
LDarki authored Feb 24, 2022
2 parents c156399 + 201e602 commit 6542240
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions AVR_Miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,16 +959,16 @@ def periodic_report(start_time, end_time, shares,

def calculate_uptime(start_time):
uptime = time() - start_time
if uptime <= 59:
return str(round(uptime)) + get_string('uptime_seconds')
elif uptime == 60:
return str(round(uptime // 60)) + get_string('uptime_minute')
elif uptime >= 60:
return str(round(uptime // 60)) + get_string('uptime_minutes')
elif uptime == 3600:
return str(round(uptime // 3600)) + get_string('uptime_hour')
elif uptime >= 3600:
return str(round(uptime // 3600)) + get_string('uptime_hours')
if uptime >= 7200: # 2 hours, plural
return str(uptime // 3600) + get_string('uptime_hours')
elif uptime >= 3600: # 1 hour, not plural
return str(uptime // 3600) + get_string('uptime_hour')
elif uptime >= 120: # 2 minutes, plural
return str(uptime // 60) + get_string('uptime_minutes')
elif uptime >= 60: # 1 minute, not plural
return str(uptime // 60) + get_string('uptime_minute')
else: # less than 1 minute
return str(round(uptime)) + get_string('uptime_seconds')


if __name__ == '__main__':
Expand Down
20 changes: 10 additions & 10 deletions PC_Miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,16 @@ def calculate_uptime(start_time):
Returns seconds, minutes or hours passed since timestamp
"""
uptime = time() - start_time
if uptime <= 59:
return str(round(uptime)) + get_string("uptime_seconds")
elif uptime == 60:
return str(round(uptime // 60)) + get_string("uptime_minute")
elif uptime >= 60:
return str(round(uptime // 60)) + get_string("uptime_minutes")
elif uptime == 3600:
return str(round(uptime // 3600)) + get_string("uptime_hour")
elif uptime >= 3600:
return str(round(uptime // 3600)) + get_string("uptime_hours")
if uptime >= 7200: # 2 hours, plural
return str(uptime // 3600) + get_string('uptime_hours')
elif uptime >= 3600: # 1 hour, not plural
return str(uptime // 3600) + get_string('uptime_hour')
elif uptime >= 120: # 2 minutes, plural
return str(uptime // 60) + get_string('uptime_minutes')
elif uptime >= 60: # 1 minute, not plural
return str(uptime // 60) + get_string('uptime_minute')
else: # less than 1 minute
return str(round(uptime)) + get_string('uptime_seconds')


def pretty_print(msg: str = None,
Expand Down

0 comments on commit 6542240

Please sign in to comment.