Skip to content

Instantly share code, notes, and snippets.

@snayler0
Created April 5, 2019 01:51
Show Gist options
  • Save snayler0/48cdb66e1a41d304421a431b8800581e to your computer and use it in GitHub Desktop.
Save snayler0/48cdb66e1a41d304421a431b8800581e to your computer and use it in GitHub Desktop.
import datetime
STARTHOUR, STARTMINUTE = map(int, input("Enter Shift Start Time (HH:MM): ").split(':'))
BREAKSTARTHOUR, BREAKSTARTMINUTE = map(int, input("Enter Break Start Time (HH:MM): ").split(':'))
BREAKENDHOUR, BREAKENDMINUTE = map(int, input("Enter Break End Time (HH:MM): ").split(':'))
ENDHOUR, ENDMINUTE = map(int, input("Enter Shift End Time (HH:MM): ").split(':'))
START_TIME = datetime.time(STARTHOUR, STARTMINUTE)
BREAKSTART_TIME = datetime.time(BREAKSTARTHOUR, BREAKSTARTMINUTE)
BREAKEND_TIME = datetime.time(BREAKENDHOUR, BREAKENDMINUTE)
END_TIME = datetime.time(ENDHOUR, ENDMINUTE)
FULL_SHIFT = datetime.timedelta(hours=END_TIME.hour, minutes=END_TIME.minute) - datetime.timedelta(hours=START_TIME.hour, minutes=START_TIME.minute)
BREAK = datetime.timedelta(hours=BREAKEND_TIME.hour, minutes=BREAKEND_TIME.minute) - datetime.timedelta(hours=BREAKSTART_TIME.hour, minutes=BREAKSTART_TIME.minute)
CHARGEABLE = FULL_SHIFT - BREAK
print("Shift time: {0}".format(FULL_SHIFT))
print("Break time: {0}".format(BREAK))
print("Chargeable time: {0}".format(CHARGEABLE))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment