Class: Tlog::Format::Seconds

Inherits:
Object
  • Object
show all
Defined in:
lib/tlog/format/seconds.rb

Class Method Summary collapse

Class Method Details

.duration(total_seconds) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/tlog/format/seconds.rb', line 4

def self.duration(total_seconds)
  output = ""
  total_seconds ||= 0
  total_seconds = total_seconds.to_i
  mm, ss = total_seconds.divmod(60)
  hh, mm = mm.divmod(60)
  output = "%2s:%02d:%02d" % [hh, mm, ss]
  return output
end