bokmann / business_time

Support for doing time math in business hours and days
MIT License
1.27k stars 215 forks source link

Handle negative business days and hours #158

Closed xlts closed 7 years ago

bokmann commented 7 years ago

Can you provide a business need / example of where negative business days/hours is used? I really appreciate the tests you've written to cover this; I just want to understand the business consideration before adding it to the gem.

xlts commented 7 years ago

@bokmann Thanks. I don't think anyone would use it deliberately like -3.business_days.before(date); this pull request basically addresses the unexpected behavior described in https://github.com/bokmann/business_time/issues/119. However, in my project I do plenty of business time calculations and often find myself adding checks in the fashion of calculated_days > 0 ? calculated_days.after(date) : calculated_days.before(date), in such case this if statement would not be needed and everything would work, well, according to the principle of least astonishment when called on negative numbers.

bokmann commented 7 years ago

Thanks for the explanation. I'll be merging this and releasing next week when I teach an internal class on release management.