forked from altayatik/sparkchallenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimeTest.py
More file actions
26 lines (18 loc) · 750 Bytes
/
timeTest.py
File metadata and controls
26 lines (18 loc) · 750 Bytes
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
from datetime import datetime
PUID = '########'
count = 1
timeFormat = '%H:%M:%S'
checkin = f'{PUID}-{count}-20:22:02'
count += 1
checkout = f'{PUID}-{count}-{str(datetime.now().strftime(timeFormat))}'
print(f'Checkin Log: {checkin}\nCheckout Log: {checkout}\n')
# Get only the time from the log
checkinTime = checkin.split('-')[2]
checkoutTime = checkout.split('-')[2]
# Update to datetime object type to allow for time algebra
checkinTime = datetime.strptime(checkinTime, timeFormat)
checkoutTime = datetime.strptime(checkoutTime, timeFormat)
print(f'Checkin Time: {checkinTime}\nCheckout Time: {checkoutTime}\n')
# Calculate difference between checkout time and check in time
diff = checkoutTime - checkinTime
print(f'Difference: {diff}')