Class: TimeHelper
- Inherits:
-
Object
- Object
- TimeHelper
- Defined in:
- lib/time_helper.rb
Class Method Summary collapse
Class Method Details
.time_difference(a, b) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/time_helper.rb', line 3 def time_difference(a, b) a, b = b, a if a < b difference = Integer(a - b) seconds = difference % 60 difference = (difference - seconds) / 60 minutes = difference % 60 difference = (difference - minutes) / 60 hours = difference % 24 result = [hours, minutes, seconds].map { |value| value.to_s.rjust(2, "0") } result.join(":") end |