Skip to content

Instantly share code, notes, and snippets.

View yurikoval's full-sized avatar
🌴
On an island in the sun

🇺🇦 Yuri Kovalov yurikoval

🌴
On an island in the sun
View GitHub Profile
@csanz
csanz / to generate a human readable time range using ruby on rails
Created November 9, 2010 18:58
to generate a human readable time range using ruby on rails
def humanize secs
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].inject([]){ |s, (count, name)|
if secs > 0
secs, n = secs.divmod(count)
s.unshift "#{n.to_i} #{name}"
end
s
}.join(' ')
end