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

potential bug in business_days.after #83

Closed
andresod opened this issue May 11, 2014 · 5 comments
Closed

potential bug in business_days.after #83

andresod opened this issue May 11, 2014 · 5 comments

Comments

@andresod
Copy link

please consider following code:

require 'json'
require 'date'
require 'business_time'

mydate = Date.parse("April 23, 2014")
printf "10 days after %d-%d-%d\n ", mydate.year, mydate.month, mydate.day
printf "using 10.business_days.after(<date>)\n"
print 10.business_days.after(mydate)
print "\n\n"
mydate = Date.parse("April 21, 2014")
printf "10 days after %d-%d-%d\n ", mydate.year, mydate.month, mydate.day
printf "using 10.business_days.after(<date>)\n"
print 10.business_days.after(mydate)
print "\n"

result:

10 days after 2014-4-23
 using 10.business_days.after(<date>)
2014-05-06 17:00:00 -0700

10 days after 2014-4-21
 using 10.business_days.after(<date>)
2014-05-05 17:00:00 -0700

expected the computed days to be 2 days apart.

@andresod
Copy link
Author

in businessdays_after, instead of:

time = Time.zone ? Time.zone.parse(time.strftime('%Y-%m-%d %H:%M:%S %z')) : Time.parse(time.strftime('%Y-%m-%d %H:%M:%S %z'))

this seems to work:

time = Time.zone ? Time.zone.parse(time.strftime('%Y-%m-%d %H:%M:%S %z')) : Time.parse(time.strftime('%Y-%m-%d %H:%M:%S'))

in other words, if time zone is not set, then don't try to parse it.

I'm just starting out with Ruby, so I might be wrong :)

@bokmann
Copy link
Owner

bokmann commented May 14, 2014

Its going to be a few days before I can fully appreciate this and release it, but it certainly seems like your line is the right thing to do. I'll hopefully incorporate and release soon.

thanks!

@pkananen
Copy link

Is this going to be merged soon?

@pkananen
Copy link

@bokmann any update?

@bokmann
Copy link
Owner

bokmann commented Apr 13, 2015

I just tested your code against the latest gem and it no longer fails. The expected 2 days apart seems to work.

@bokmann bokmann closed this as completed Apr 13, 2015
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