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

The method from_now of Class: BusinessTime::BusinessDays returns different results under the same context #221

Open
ArminBeda opened this issue Dec 30, 2022 · 6 comments

Comments

@ArminBeda
Copy link

ArminBeda commented Dec 30, 2022

The Method from_now of Class: BusinessTime::BusinessDays is used to calculate a specific date in a Ruby on Rails application. Sometimes (only sometimes!) wrong date was delivered back at a specific point. I just could not find out what the problem is, until I placed the following lines into my code, just for the sake of experiementing:

puts "500.business_days&.from_now1: #{500.business_days&.from_now}"
puts "500.business_days&.from_now2: #{500.business_days&.from_now}"
puts "500.business_days&.from_now3: #{500.business_days&.from_now}"
puts "500.business_days&.from_now4: #{500.business_days&.from_now}"
puts "500.business_days&.from_now5: #{500.business_days&.from_now}"
puts "500.business_days&.from_now6: #{500.business_days&.from_now}"
puts "500.business_days&.from_now7: #{500.business_days&.from_now}"

This is the screenshot, what was returned on the console:

image

Here is a content of the console as text:

500.business_days&.from_now1: 2024-12-30 09:00:00 +0100
500.business_days&.from_now2: 2024-12-30 09:00:00 +0100
500.business_days&.from_now3: 2024-11-29 09:00:00 +0100
500.business_days&.from_now4: 2024-12-19 09:00:00 +0100
500.business_days&.from_now5: 2024-12-30 09:00:00 +0100
500.business_days&.from_now6: 2024-12-30 09:00:00 +0100
500.business_days&.from_now7: 2024-12-30 09:00:00 +0100

As you see, sometimes the Date 2024-11-29 is returned but sometimes 2024-12-30.

This might be a bug, or something I do not understand.

@bokmann
Copy link
Owner

bokmann commented Dec 30, 2022

What version of Ruby are you using?

@ArminBeda
Copy link
Author

What version of Ruby are you using?

3.0.5

@rmm5t
Copy link
Collaborator

rmm5t commented Dec 31, 2022

I have not been able to reproduce this yet:

>> RUBY_VERSION
=> "3.0.5"
?> def run
?>   50.times { |i| puts "500.business_days.from_now#{i}: #{500.business_days.from_now}" }
>> end
=> :run
>> run
500.business_days.from_now0: 2024-12-02 09:00:00 -0700
# (... all the same)
500.business_days.from_now49: 2024-12-02 09:00:00 -0700
=> 50

What kind of holiday and/or other configuration are you using?

@ArminBeda
Copy link
Author

ArminBeda commented Jan 2, 2023

@rmm5t

If I run the line 50.times { |i| puts "500.business_days.from_now#{i}: #{500.business_days.from_now}" } on the console as you did, I also cannot reproduce the effect.

But if I just randomly put the line into a method in the code which is triggered in a cucumber test scenario, then I can reproduce the effect:

image

@ArminBeda
Copy link
Author

@rmm5t is there any update on the issue? the bug is still present

@rmm5t
Copy link
Collaborator

rmm5t commented Mar 1, 2023

No updates.

Again, What kind of holiday and/or other configuration are you using?

There’s not much I can do here without a way to reproduce this. If you can submit a PR with a test that exhibits the behavior that you’re seeing, that would go a long way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants