Skip to content

Instantly share code, notes, and snippets.

@cybardev
Last active October 13, 2023 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cybardev/5b05c5d37d60aa90152a65659fb97711 to your computer and use it in GitHub Desktop.
Save cybardev/5b05c5d37d60aa90152a65659fb97711 to your computer and use it in GitHub Desktop.
Pomodoro Breakdown Calculator
#!/usr/bin/env python3
from dataclasses import dataclass
@dataclass
class Pomodoro:
work_hours: int
def __post_init__(self) -> None:
self._time: dict = {
"total": self.work_hours * 60,
"work": 0,
"short_break": 0,
"long_break": 0,
}
@property
def duration(self) -> dict:
return {
"work": 25,
"short_break": 5,
"long_break": 30,
}
def _rem(self, session) -> int:
duration = self.duration[session]
self._time[session] += duration
self._time["total"] -= duration
return self._time["total"]
def pomo(self) -> int:
for _ in range(4):
self._rem("work")
self._rem("short_break")
self._rem("long_break")
return self._time["total"]
def __str__(self) -> str:
s = f"In {self.work_hours:02d} hours, you had...\n"
s += f"Work : {int(self._time['work'] // 60):02d} hours"
s += f" and {int(self._time['work'] % 60):02d} minutes\n"
s += f"Breaks : {int((self._time['short_break'] + self._time['long_break']) // 60):02d} hours"
s += f" and {int((self._time['short_break'] + self._time['long_break']) % 60):02d} minutes\n"
s += f"Remaining : {int(self._time['total'] // 60):02d} hours"
s += f" and {int(self._time['total'] % 60):02d} minutes"
return s
if __name__ == "__main__":
p = Pomodoro(int(input("Enter total work hours: ")))
while p.pomo() > 60:
pass
print(str(p))
@cybardev
Copy link
Author

Pomodoro Breakdown Calculator

This script tells you how much you'll work, have breaks, and the remaining time. given total number of hours worked using a Pomodoro timer.

Example Output:

Enter total work hours: 8
In 08 hours, you had...
Work      : 05 hours and 00 minutes
Breaks    : 02 hours and 30 minutes
Remaining : 00 hours and 30 minutes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment