Module: Course::StatisticsHelper

Defined in:
app/helpers/course/statistics_helper.rb

Instance Method Summary collapse

Instance Method Details

#seconds_to_str(total_seconds) ⇒ Object

Convert time in seconds to HH:MM:SS format.


4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/course/statistics_helper.rb', line 4

def seconds_to_str(total_seconds)
  return '--:--:--' unless total_seconds

  seconds = total_seconds % 60
  minutes = (total_seconds / 60) % 60
  hours = (total_seconds / (60 * 60)) % 24
  days = total_seconds / (60 * 60 * 24)

  format("%2d #{t('time.day')} %02d:%02d:%02d", days, hours, minutes, seconds)
end