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

inconsistent business day calculation between sunday afternoon and monday AM #136

Open
philrosenstein opened this issue Aug 15, 2016 · 2 comments

Comments

@philrosenstein
Copy link

When calculating 0.business_days.from_now on a Sunday, I am given Tuesday. But then if I run 0.business_days.from_now again before the start of business on Monday, I am finally given Monday..

Run on Sunday afternoon:

[1] pry(main)> 1.business_day.from_now
=> Wed, 17 Aug 2016 09:00:00 EDT -04:00
[2] pry(main)> 0.business_day.from_now
=> Tue, 16 Aug 2016 09:00:00 EDT -04:00
[3] pry(main)> 0.business_day.ago
=> Fri, 12 Aug 2016 09:00:00 EDT -04:00
[4] pry(main)> 1.business_day.ago
=> Thu, 11 Aug 2016 09:00:00 EDT -04:00

Run on Monday at 8 am EDT:

[5] pry(main)> 0.business_day.from_now
=> Mon, 15 Aug 2016 09:00:00 EDT -04:00
[6] pry(main)> 1.business_day.from_now
=> Tue, 16 Aug 2016 09:00:00 EDT -04:00

@craiglittle
Copy link

@philrosenstein Have you considered the biz gem? (I'm the maintainer.)

It exhibits behavior that might fit your use case well:

>> SUNDAY_AFTERNOON = Time.utc(2016, 8, 14, 14)
=> 2016-08-14 14:00:00 UTC
>> MONDAY_MORNING = Time.utc(2016, 8, 15, 8)
=> 2016-08-15 08:00:00 UTC

>> 1.business_day.after(SUNDAY_AFTERNOON)
=> 2016-08-15 14:00:00 UTC
>> 0.business_days.after(SUNDAY_AFTERNOON)
=> 2016-08-15 09:00:00 UTC
>> 0.business_days.before(SUNDAY_AFTERNOON)
=> 2016-08-12 17:00:00 UTC
>> 1.business_day.before(SUNDAY_AFTERNOON)
=> 2016-08-12 14:00:00 UTC

>> 0.business_days.after(MONDAY_MORNING)
=> 2016-08-15 09:00:00 UTC
>> 1.business_day.after(MONDAY_MORNING)
=> 2016-08-16 09:00:00 UTC

@bokmann
Copy link
Owner

bokmann commented Mar 6, 2017

this seems to be related to #149

I'll get a test case and investigate

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