module Lono::Utils::PrettyTime

Public Instance Methods

pretty_time(total_seconds) click to toggle source

stackoverflow.com/questions/4175733/convert-duration-to-hoursminutesseconds-or-similar-in-rails-3-or-ruby

# File lib/lono/utils/pretty_time.rb, line 4
def pretty_time(total_seconds)
  minutes = (total_seconds / 60) % 60
  seconds = total_seconds % 60
  if total_seconds < 60
    "#{seconds.to_i}s"
  else
    "#{minutes.to_i}m #{seconds.to_i}s"
  end
end