Module: Barbeque::JobDefinitionsHelper

Defined in:
app/helpers/barbeque/job_definitions_helper.rb

Instance Method Summary collapse

Instance Method Details

#distance_of_time(from, to) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/barbeque/job_definitions_helper.rb', line 2

def distance_of_time(from, to)
  return '' if from.nil? || to.nil?

  secs  = (to - from).to_i
  mins  = secs / 60
  hours = mins / 60
  days  = hours / 24

  text = "%02d:%02d:%02d" % [hours % 24, mins % 60, secs % 60]
  text.prepend("#{days}days ") if days > 0
  text
end