I did not find the Ruby-ish seconds_to_hours function (although it is trivial to build), but at the bottom of this post there is an obvious solution.
s = Time.now e = Time.now + 3.hours d = e - s => 10803.318176
Note. This value is simply a float representing seconds between two date values.
I would like him to come back. To do this, you divide the time, in seconds.
b = d / 1.hour.seconds => 3.0009217155555556
My goal was to get the decimal value of the clock, rounded to the next 6 minutes, like this:
r = b.round(1) => 3.0
Summarizing:
r = ((e - s) / 1.hour.seconds).round(1) => 3.0
source share