Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handling negative business hours & days #119

Open
paulcc opened this issue Sep 11, 2015 · 2 comments
Open

handling negative business hours & days #119

paulcc opened this issue Sep 11, 2015 · 2 comments

Comments

@paulcc
Copy link

paulcc commented Sep 11, 2015

At present, negative values are accepted but basically treated as zero. Compare:

irb> 1.hour.ago
 => Fri, 11 Sep 2015 11:41:00 BST +01:00

irb> (-10).days.since(1.hour.ago)
 => Tue, 01 Sep 2015 11:41:00 BST +01:00

irb> (-10).business_days.since(1.hour.ago)
 => Fri, 11 Sep 2015 11:41:00 BST +01:00

Maybe it's a bit daft to try to use negative business days or hours, but people like me will still try to do it! (Having negatives does simplify some interval-based calculations, and Rails does the sensible thing already.)

One option is to get (-x).business_FOO.since(y) to call x.business_FOO.before(y). Even throwing an exception would be better than silently doing nothing.

ps. still a very handy gem - thanks!

@bokmann
Copy link
Owner

bokmann commented Feb 3, 2016

Not a bad suggestion, but not one I have the time or inclination to research. I'll gladly accept a pull request with appropriate tests though.

@xlts
Copy link
Contributor

xlts commented May 5, 2017

@bokmann I created a pull request according to suggestions in the above post, see #158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants