I have only found question Convert Days and Time (Hours x Minutes x Seconds) to Time only on stackoverflow and that seems like it would help me out but it doesn't seem to totally apply to what I'm doing.
I'm writing a wage tracking program and need it to give me the total sum of all hour input. I've got a much smaller and abridged form of it to just work on this one aspect. It saves a lot of time as the main program requires all the individual start and end times to be input by the user. It is currently showing 2 days, 22:00:00
as on output whereas I ideally would prefer it to show 70:00
, showing only the hours and minutes and getting rid of the unneeded second part.
import datetime
def time_diff(a, b): # Calculates time difference between start and finish
return b - a
start = '10:00'
mon_start = datetime.datetime.strptime(start, '%H:%M')
finish = '20:00'
mon_fin = datetime.datetime.strptime(finish, '%H:%M')
mon_hours = time_diff(mon_start, mon_fin)
start = '10:00'
tue_start = datetime.datetime.strptime(start, '%H:%M')
finish = '20:00'
tue_fin = datetime.datetime.strptime(finish, '%H:%M')
tue_hours = time_diff(tue_start, tue_fin)
start = '10:00'
wed_start = datetime.datetime.strptime(start, '%H:%M')
finish = '20:00'
wed_fin = datetime.datetime.strptime(finish, '%H:%M')
wed_hours = time_diff(wed_start, wed_fin)
start = '10:00'
thu_start = datetime.datetime.strptime(start, '%H:%M')
finish = '20:00'
thu_fin = datetime.datetime.strptime(finish, '%H:%M')
thu_hours = time_diff(thu_start, thu_fin)
start = '10:00'
fri_start = datetime.datetime.strptime(start, '%H:%M')
finish = '20:00'
fri_fin = datetime.datetime.strptime(finish, '%H:%M')
fri_hours = time_diff(fri_start, fri_fin)
start = '10:00'
sat_start = datetime.datetime.strptime(start, '%H:%M')
finish = '20:00'
sat_fin = datetime.datetime.strptime(finish, '%H:%M')
sat_hours = time_diff(sat_start, sat_fin)
start = '10:00'
sun_start = datetime.datetime.strptime(start, '%H:%M')
finish = '20:00'
sun_fin = datetime.datetime.strptime(finish, '%H:%M')
sun_hours = time_diff(sun_start, sun_fin)
total_hours = mon_hours + tue_hours + wed_hours + thu_hours + fri_hours + sat_hours + sun_hours
print(total_hours)