class Envirobly::Duration

def format_duration(tms)

def format_duration(tms)
  ms = (tms.real * 1000).to_i
  if ms >= 60_000
    minutes = ms / 60_000
    seconds = (ms % 60_000) / 1000
    sprintf("%dm%ds", minutes, seconds)
  elsif ms >= 1000
    seconds = ms / 1000
    sprintf("%ds", seconds)
  else
    sprintf("%dms", ms)
  end
end