business_time icon indicating copy to clipboard operation
business_time copied to clipboard

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

Open rchady opened this issue 11 years ago • 4 comments

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.

rchady avatar Aug 21 '13 16:08 rchady

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 avatar Oct 25 '13 11:10 bokmann

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.

rchady avatar Oct 25 '13 15:10 rchady

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

bokmann avatar Oct 27 '13 15:10 bokmann

this may be related to issue #83

andresod avatar May 11 '14 21:05 andresod