def humanize_time(secs)
      [[60, :s], [60, :m], [24, :h], [1000, :d]].map { |count, name|
        if secs.positive?
          secs, n = secs.divmod(count)
          "#{n.to_i}#{name}"
        end
      }.compact.reverse.join(' ')
    end
def humanize_time(secs)
      [[60, :s], [60, :m], [24, :h], [1000, :d]].map { |count, name|
        if secs.positive?
          secs, n = secs.divmod(count)
          "#{n.to_i}#{name}"
        end
      }.compact.reverse.join(' ')
    end
from http://stackoverflow.com/questions/4136248