Convert seconds to compound duration: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: add ruby sample) |
|||
Line 975: | Line 975: | ||
h, rem = rem.divmod(HOUR) |
h, rem = rem.divmod(HOUR) |
||
m, s = rem.divmod(MINUTE) |
m, s = rem.divmod(MINUTE) |
||
units =["#{w} wk", "#{d} d","#{h} h", "#{m} min", "#{s} sec"] |
units = ["#{w} wk", "#{d} d", "#{h} h", "#{m} min", "#{s} sec"] |
||
units.reject{|str| str.start_with?("0")}.join(", ") |
units.reject{|str| str.start_with?("0")}.join(", ") |
||
end |
end |