Skip to content

Commit

Permalink
Improve show_time() function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tage Johansson committed Mar 18, 2024
1 parent 04bc6e5 commit 7e62aa5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions chess_cli/utils.py
Expand Up @@ -183,8 +183,14 @@ def show_time(secs: float, decimals: int = 1) -> str:
secs %= 60
res = ""
if hours != 0:
res += f"{hours} hours "
res += f"{hours} hour"
if hours != 1:
res += "s"
res += " and " if minutes == 0 else ", "
if minutes != 0:
res += f"{minutes} minutes "
res += f"{minutes} minute"
if minutes != 1:
res += "s"
res += " and "
res += f"{secs:.{decimals}f} seconds"
return res

0 comments on commit 7e62aa5

Please sign in to comment.