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

Timedelta to businesshours support #20

Open csoare7 opened 6 years ago

csoare7 commented 6 years ago

First of all, thank you very much for your work on this library.

I found myself slightly confused when trying to extract business hours from the timedelta result.

>>> d1 = datetime.datetime(2017, 5, 23, 9, 0) >>> d2 = datetime.datetime(2017, 5, 24, 9, 0) >>> r = BusinessTime().businesstimedelta(d1, d2) datetime.timedelta(1)

My immediate thought to extract the business hours (which in this case it's 8) was to call timedelta.total_seconds() method on the result, but this will return the equivalent of 24 hours in seconds, not 8 hours - given it has no knowledge of the business_hours in the BusinessTime object.

This experience proved a bit confusing and was wondering if you might be able to suggest a solution to this? Would a PR would be accepted for this sort of functionality?

josegonzalez commented 6 years ago

Go for it.