File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
days/01-03-datetimes/code Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ from datetime import datetime , timedelta
2
+ import time
3
+
4
+ POMODORO_INTERVAL = 25
5
+
6
+
7
+ def main ():
8
+ start_time = datetime .now ()
9
+ print (f"Starting timer at { start_time } " )
10
+ print ()
11
+ pomodoro_count (start_time )
12
+ return
13
+
14
+
15
+ def pomodoro_count (start ):
16
+ duration = timedelta (minutes = POMODORO_INTERVAL )
17
+
18
+ for t in range (duration .seconds + 1 ):
19
+ current_increment = start + timedelta (seconds = 1 )
20
+ print ("\r " , f"Elapsed time: { format_counter (t )} m:s" , end = "" )
21
+ # print(f"Elapsed time: {t} seconds")
22
+ time .sleep (1 )
23
+
24
+ print ()
25
+ print (f"Stopping timer at { datetime .now ()} " )
26
+
27
+
28
+ def format_counter (seconds ):
29
+ return f"{ int (seconds / 60 )} :{ int (seconds % 60 )} "
30
+
31
+
32
+ if __name__ == "__main__" :
33
+ main ()
You can’t perform that action at this time.
0 commit comments