seatgeek / businesstime

A simple python utility for calculating business time aware timedeltas between two datetimes
BSD 2-Clause "Simplified" License
85 stars 36 forks source link

Time delta calculation bug when both start and end times are after hours #13

Closed brox closed 6 years ago

brox commented 8 years ago

This piece of code returns the wrong time delta:

>>> bt=BusinessTime()
>>> bt.businesstimedelta(datetime(2016, 6, 17, 18), datetime(2016, 6, 20, 18))
datetime.timedelta(0)

The start time is after hours on a Friday at 6pm, while the end time is after hours on the following Monday at 6pm. The correct answer should be datetime.timedelta(1), right?

flc commented 8 years ago

assuming bt.business_hours is (datetime.time(9, 0), datetime.time(17, 0)) and bt.weekends is (5, 6)shouldn't this be equal to bt.businesstimedelta(datetime.datetime(2016, 6, 20, 9, 0), datetime.datetime(2016, 6, 20, 17, 0)) ? which is: datetime.timedelta(0, 28800)

josegonzalez commented 6 years ago

Closed by #22