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

Breaks for holidays in the past #145

Open
thebucknerlife opened this issue Nov 28, 2016 · 2 comments
Open

Breaks for holidays in the past #145

thebucknerlife opened this issue Nov 28, 2016 · 2 comments

Comments

@thebucknerlife
Copy link

thebucknerlife commented Nov 28, 2016

Updated: see my updated comment below.

Hi! Firstly, thanks for the helpful gem!

Noticed some surprising functionality over the weekend. We've been developing our app over the last few months using this gem. In our specs, we used Thanksgiving 2016 (last Thursday). Come Friday, our tests started breaking. Doing some digging, I discovered that business_time doesn't support holidays in the past.

(byebug) Time.now
2016-11-28
(byebug) Date.parse("2017-11-24").workday? # Thanksgiving 2016, now in the past
false
(byebug) Date.parse("2017-12-25").workday? # Christmas 2016, still in the future
true

Checking the config confirmed my suspicions since Thanksgiving was no longer in the list of holidays.

I was surprised by this functionality because of this example in the README for the Gem:

And we can do it from any Date or Time object.

my_birthday = Date.parse("August 4th, 1969")
8.business_days.after(my_birthday)
8.business_days.before(my_birthday)

my_birthday = Time.parse("August 4th, 1969, 8:32 am")
8.business_days.after(my_birthday)
8.business_days.before(my_birthday)```

This example would not work if there was a holiday around that birthday.

Possible solutions:

  • Add support for the most common holidays for the last 10, 20, 50, 100 years? (probably outside the scope of this gem, tho)
  • Clearly state in the README this is future looking only. And update that example quoted above.

I've fixed our specs by adding Thanksgiving 2016 to the config in the test suite, so we're all good.

And I'm happy to update the README in a PR, just let me know! Thanks!

@thebucknerlife
Copy link
Author

Just realized there is a dependency between this and the Holidays gem we're using. So this is less expected than I thought. I'd suggest the README should note that the gem comes with no holidays out of the box, so the support of future or past holidays is dependent on the config?

@bokmann
Copy link
Owner

bokmann commented Mar 6, 2017

Yes, it is up to you to configure hoidays. The docs reference the holidays gem and point to another article, and this was contributed by someone else. If you'd like to write u your discovery and give me a pull request, I'll gladly take it.

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

2 participants