bokmann / business_time

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

Still finding problems next business day for mondays #186

Closed ekampp closed 5 years ago

ekampp commented 5 years ago

This is basically the same problem as reported for #111, which was closed because of #113.

However, that was a long time ago, and I'm running Ruby v. 2.5.3 and still seeing problems with determening monday as the next businessday after a weekend.

And because of the huge time and version disparity between now and the older versions, I'm opening a new ticket.

$ d = Date.parse("2015-03-28")
=> Sat, 28 Mar 2015
$ 1.business_days.after(d)
=> Tue, 31 Mar 2015
$ d = Date.parse("2015-03-29")
=> Sun, 29 Mar 2015
$ 1.business_days.after(d)
=> Tue, 31 Mar 2015

So today, as of writing this bug, it's Sunday, and I'm getting these results:

$ Time.zone.now
=> Sun, 09 Dec 2018 11:15:24 UTC +00:00
$ 1.business_hour.from_now
=> Mon, 10 Dec 2018 10:00:00 UTC +00:00
$ 1.business_day.from_now
=> Tue, 11 Dec 2018 11:15:18 UTC +00:00

So as you can see, business hours correctly figure out that Monday is the next business day, while business days does not.

pmcnano commented 5 years ago

I was just going to post this. Just as an FYI doing

Time.first_business_day(sunday_date) does return Monday.

bokmann commented 5 years ago

As documented in many places, this is not a defect. This gem was originally used for calculating due dates of work. If you are assigned a task over a weekend, and you have one business day to work on it, that is Tuesday. If you're assigned it over a weekend and given one hour to work on it, then that is monday. Think of it as saying "this task is due in 0 days and 1 hour" vs. "this is is due in 1 day".

ekampp commented 5 years ago

@bokmann, so what about the patch in #190, are you going to merge that at some point, or leave it as it is?