File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ from datetime import datetime , timedelta
2+ from time import sleep
3+ import os
4+
5+
6+ def cls ():
7+ os .system ('cls' if os .name == 'nt' else 'clear' )
8+
9+
10+ def timer (duration : timedelta , state_name : str ,
11+ start_time : datetime = None ):
12+ if start_time is None :
13+ start_time = datetime .now ()
14+ while (datetime .now () < start_time + duration ):
15+ cls ()
16+ now = datetime .now ()
17+ print (f"In { state_name } .." )
18+ print (f"Current Time is { now } " )
19+ print (f"{ state_name } ends at { start_time + duration } " )
20+ print (f"Time left: { start_time + duration - now } " )
21+ print ("^C to quit" )
22+ sleep (1 )
23+
24+
25+ def start_pomodoro (pomodoro_delta : timedelta , break_delta : timedelta ):
26+ in_pomodoro_state = True
27+ while 1 :
28+ if in_pomodoro_state :
29+ timer (duration = pomodoro_delta , state_name = "Pomodoro" )
30+ else :
31+ timer (duration = break_delta , state_name = "Break" )
32+ in_pomodoro_state = not (in_pomodoro_state )
33+
34+
35+ pomodoro_minutes = int (input ("Enter your Pomodoro Time in minutes: " ))
36+ pomodoro_timedelta = timedelta (minutes = pomodoro_minutes )
37+
38+ break_minutes = int (input ("Enter your Break Time in minutes: " ))
39+ break_timedelta = timedelta (minutes = break_minutes )
40+
41+ start_pomodoro (pomodoro_timedelta , break_timedelta )
You can’t perform that action at this time.
0 commit comments