Module: RspecN::TimeHelpers

Included in:
Formatters::FileFormatter, Formatters::TableFormatter
Defined in:
lib/rspec_n/helpers/time_helpers.rb

Instance Method Summary collapse

Instance Method Details

#convert_seconds_to_hms(total_seconds) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/rspec_n/helpers/time_helpers.rb', line 3

def convert_seconds_to_hms(total_seconds)
  hours = total_seconds / (60 * 60)
  minutes = (total_seconds / 60) % 60
  seconds = total_seconds % 60
  [hours, minutes, seconds].map do |t|
    # Right justify and pad with 0 until length is 2.
    # So if the duration of any of the time components is 0, then it will display as 00
    t.round.to_s.rjust(2, '0')
  end.join(':')
end