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

business_day.after does not handle starting time outside business hours properly #45

Open
rchady opened this issue Aug 21, 2013 · 4 comments

Comments

@rchady
Copy link

rchady commented Aug 21, 2013

The latest version of business_time does not seem to handle calculating business_days.after() based on a date/time that starts outside business hours.
An example:

irb(main):001:0> d=Time.parse("Saturday, August 17, 12:54am")
=> Sat Aug 17 00:54:00 -0700 2013
irb(main):002:0> 1.business_day.after(d)
=> Tue, 20 Aug 2013 00:54:00 PDT -07:00

It seems that business_days.after is completely ignoring the time, which seems to be wrong. It also seems to have the day off by one as 1 business day after should be the EOBD on Monday.

@bokmann
Copy link
Owner

bokmann commented Oct 25, 2013

This is correct behavior. Here's what happens:

  1. Saturday, August 17th at 12:54 am is not a business day.
  2. We roll forward. the next business day starts Monday morning at Monday, August 19th at 0700PDT
  3. We add one business day to that, and you get Tuesday morning.

This matches the real world scenario of a company saying "We will process your paperwork within one business day", and has mail delivery on Saturday. The busines day clock doesn't start until Monday morning for the mail that arrived Saturday.

@bokmann bokmann closed this as completed Oct 25, 2013
@rchady
Copy link
Author

rchady commented Oct 25, 2013

The date was not the issue, the time was. The resulting time is 00:54:00 which is not inside business hours. The rest of your logic I follow and agree with… but the resulting time is not correct. Note that using business_hours.after() works fine, it is just business_days.after() that does not.

@bokmann
Copy link
Owner

bokmann commented Oct 27, 2013

Hmm... I agree, this seems like a real issue.

@bokmann bokmann reopened this Oct 27, 2013
@andresod
Copy link

this may be related to issue #83

dugjason added a commit to dugjason/business_time that referenced this issue Oct 19, 2015
dugjason added a commit to dugjason/business_time that referenced this issue Oct 19, 2015
…Ensure we wind to beginning of business day when using business_hours before/after methods
bokmann added a commit that referenced this issue Feb 3, 2016
Fixes for issues #36, #45 and #83 (bug in business_days.before/after)
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