-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
29 lines (26 loc) · 1.01 KB
/
models.py
File metadata and controls
29 lines (26 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class TimeTrackerState:
def __init__(self):
self.sheet = None
self.current_client = None
self.is_clocked_in = False
self.current_row = None
self.active_start = None
self.total_active = 0
self.last_activity = None
self.current_activity = "Active"
def clock_in(self, row_index, start_time):
self.is_clocked_in = True
self.current_row = row_index
self.active_start = start_time
self.total_active = 0
self.last_activity = start_time
self.current_activity = "Active"
def clock_out(self, end_time):
if self.active_start:
self.total_active += (end_time - self.active_start).seconds
self.is_clocked_in = False
def get_total_seconds(self, current_time):
elapsed = self.total_active
if self.is_clocked_in and self.current_activity == "Active" and self.active_start:
elapsed += (current_time - self.active_start).seconds
return elapsed