Skip to content

Commit

Permalink
Total hours studied are rounded
Browse files Browse the repository at this point in the history
  • Loading branch information
jake158 committed May 9, 2024
1 parent a1fa6ef commit 15e677c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/logic/richpresence.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ def disconnect(self):
self.connected = True
return False

def format_time(self, seconds_studied):
def format_time(self, seconds_studied, round_hours_to=1):
total_seconds = seconds_studied
total_hours = seconds_studied / 3600
if total_hours < 1:
return f"{total_seconds // 60} minute{'s' if total_seconds // 60 != 1 else ''}"
else:
return f"{round(total_hours, 1) if total_hours % 1 != 0 else int(total_hours)} hours"
return f"{round(total_hours, round_hours_to) if total_hours % 1 != 0 else int(total_hours)} hours"

@_handle_exceptions
def idling_state(self, seconds_studied=0):
self.update(state=f"Total time studied: {self.format_time(self.total_seconds_studied + seconds_studied)}",
self.update(state=f"Total time studied: {self.format_time(self.total_seconds_studied + seconds_studied, None)}",
details="Idling",
start=self.launch_time,
large_image="graytomato",
Expand Down

0 comments on commit 15e677c

Please sign in to comment.