|
|
@ -363,5 +363,28 @@ class TimeBot: |
|
|
|
start_date=now.replace(hour=0, minute=0, second=0, microsecond=0), |
|
|
|
start_date=now.replace(hour=0, minute=0, second=0, microsecond=0), |
|
|
|
end_date=now.replace(hour=0, minute=0, second=0, microsecond=0), |
|
|
|
end_date=now.replace(hour=0, minute=0, second=0, microsecond=0), |
|
|
|
) |
|
|
|
) |
|
|
|
time_delta = now - datetime.datetime.strptime(punches[-1]["dateTime"], DateFormats.FULL_DATETIME.value) |
|
|
|
punch_out_time = now |
|
|
|
|
|
|
|
if punches and punches[0]["entryNumber"] == PunchCodes.LEAVING.value: |
|
|
|
|
|
|
|
punch_out_time = datetime.datetime.strptime(punches.pop(0)["dateTime"], DateFormats.FULL_DATETIME.value) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
punch_in_time = None |
|
|
|
|
|
|
|
if punches and punches[-1]["entryNumber"] == PunchCodes.COMING.value: |
|
|
|
|
|
|
|
punch_in_time = datetime.datetime.strptime(punches.pop(-1)["dateTime"], DateFormats.FULL_DATETIME.value) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if punch_in_time is None: |
|
|
|
|
|
|
|
return datetime.timedelta(seconds=0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
breaks = [] |
|
|
|
|
|
|
|
end = now |
|
|
|
|
|
|
|
for i in punches: |
|
|
|
|
|
|
|
if i["entryNumber"] == PunchCodes.BREAK_END.value: |
|
|
|
|
|
|
|
end = datetime.datetime.strptime(i["dateTime"], DateFormats.FULL_DATETIME.value) |
|
|
|
|
|
|
|
if i["entryNumber"] == PunchCodes.BREAK_START.value: |
|
|
|
|
|
|
|
start = datetime.datetime.strptime(i["dateTime"], DateFormats.FULL_DATETIME.value) |
|
|
|
|
|
|
|
breaks.append(end - start) |
|
|
|
|
|
|
|
end = now |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
time_delta = punch_out_time - punch_in_time |
|
|
|
|
|
|
|
for i in breaks: |
|
|
|
|
|
|
|
time_delta = time_delta - i |
|
|
|
return time_delta |
|
|
|
return time_delta |
|
|
|