Hello,
Assuming
- we are in a full working day (00:00:00-23:59:59)
- Time.zone = 'Paris'
current issue is :
5.hours.ago.business_time_until 1.hours.ago
# => 7200.00005698204 // 2 hours
5.hours.ago.to_time.business_time_until 1.hours.ago.to_time
# => 14400.000063 // 4 hours
So 5 hours - 1 hours = 4 hours, the correct result is :
5.hours.ago.to_time.business_time_until 1.hours.ago.to_time
So why these 2 results are different ?
5.hours.ago.class
# => ActiveSupport::TimeWithZone
5.hours.ago.to_time
# => Time
Basically the main difference is the class used when dealing with business_time_until Time vs ActiveSupport::TimeWithZone
https://github.com/bokmann/business_time/blob/master/lib/business_time/core_ext/time.rb#L100 when using an ActiveSupport::TimeWithZone, it is converted to Time without converting using timezone properly.
I know that business_time is timezone agnostic, but using rails .ago, .from_now helpers are pretty convenient.
Any feedback is appreciated :) !
Hello,
Assuming
current issue is :
So 5 hours - 1 hours = 4 hours, the correct result is :
So why these 2 results are different ?
Basically the main difference is the class used when dealing with business_time_until Time vs ActiveSupport::TimeWithZone
https://github.com/bokmann/business_time/blob/master/lib/business_time/core_ext/time.rb#L100 when using an ActiveSupport::TimeWithZone, it is converted to Time without converting using timezone properly.
I know that business_time is timezone agnostic, but using rails .ago, .from_now helpers are pretty convenient.
Any feedback is appreciated :) !