Skip to content

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

@ArminBeda

Description

@ArminBeda

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions