app/helpers/episodes_helper.rb
# Given a duration in seconds, returns a colon-separated formatted duration.
# For example, 350 seconds becomes "0:05:50".
#
# @param [Integer] seconds A duration in seconds.
# @return [String] The formatted duration as colon-separated components.
Given a duration in seconds, returns a colon-separated formatted duration.
Given a duration in seconds returns a colon - separated formatted duration .
def duration_string(seconds)
    seconds = seconds.round
    hours   = (seconds / 3600)
    minutes = (seconds - (hours * 3600)) / 60
    seconds = seconds - (hours * 3600) - (minutes * 60)
    return [
        hours.to_s,
        minutes.to_s.rjust(2, '0'),
        seconds.to_s.rjust(2, '0')
    ].join(':')
  end
def duration_string ( seconds ) seconds = seconds . round hours = ( seconds / 3600 ) minutes = ( seconds - ( hours * 3600 ) ) / 60 seconds = seconds - ( hours * 3600 ) - ( minutes * 60 ) return [ hours . to_s , minutes . to_s . rjust ( 2 , '0' ) , seconds . to_s . rjust ( 2 , '0' ) ] . join ( ':' ) end
Given a duration in seconds, returns a colon-separated formatted duration.
Given a duration in seconds returns a colon - separated formatted duration .
The formatted duration as colon-separated components.
The formatted duration as colon - separated components .
String
seconds
<not_specific>
<not_specific>
seconds A duration in seconds.
seconds A duration in seconds .