Calculation of business hours between two time

Viewed 28

I would like to write a function that calculate working business hours in python, to do that I don't like to define a class and use python ready function to calculate.

I tried with following code but this is not what I wanted. do you have any suggestion?

import datetime

start_time = datetime.datetime(2019, 12, 1, 22, 45, 25)
end_time = datetime.datetime(2019, 12, 7, 10, 00, 00)

hours = BusinessHours(start_time, end_time, worktiming=[9, 18], weekends=[6, 7], holidayfile=None)
print(hours.gethours())

I would like to have an input as of "2019-12-01 09:30:00" and "2019-12-07 12:15:00" and the output should be 40 hours

0 Answers
Related