bokmann / business_time

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

business_time_until doesn't account for holidays when called on Time objects #175

Open s-v-z opened 7 years ago

s-v-z commented 7 years ago

The title is quite self-explanatory. busines_time_until returns inconsistent results when called on Time/DateTime objects and holidays are within the range.

Below is an example of such an inconsistency.

2.1.5 :017 > BusinessTime::Config.holidays.clear
=> #<SortedSet: {}>
2.1.5 :018 > BusinessTime::Config.holidays << Date.new(2017,10,18)
=> #<SortedSet: {Wed, 18 Oct 2017}>
2.1.5 :019 > start = Time.new(2017,10,16)
=> 2017-10-16 00:00:00 +0300
2.1.5 :020 > fin = Time.new(2017,10,20)
=> 2017-10-20 00:00:00 +0300
2.1.5 :021 > start.business_time_until(fin) / 3600
=> 27.0
2.1.5 :022 > (start.to_datetime.business_time_until(fin.to_datetime)).to_f / 3600
=> 18.000104166666667
bokmann commented 6 years ago

Will investigate.