Last active
October 13, 2023 14:45
-
-
Save cybardev/5b05c5d37d60aa90152a65659fb97711 to your computer and use it in GitHub Desktop.
Pomodoro Breakdown Calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: