Wednesday, September 26, 2007

helper: s_to_hh_mm_ss

Convert seconds to hh:mm:ss


def s_to_hh_mm_ss(number)
seconds = "%02d" % (number % 6)
minutes = "%02d" % ( (number / 60 ) % 60)
hours = "%02d" % ( (number / 3600) % 24)

return (hours + minutes + seconds).scan(/../).join(':')
end

No comments: