3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/tepoch/util.rb', line 3
def self.seconds_to_string(s)
m = (s / 60).floor
s = s % 60
h = (m / 60).floor
m = m % 60
d = (h / 24).floor
h = h % 24
output = "#{s} second#{Util.pluralize(s)}" if (s > 0)
output = "#{m} minute#{Util.pluralize(m)}, #{s} second#{Util.pluralize(s)}" if (m > 0)
output = "#{h} hour#{Util.pluralize(h)}, #{m} minute#{Util.pluralize(m)}, #{s} second#{Util.pluralize(s)}" if (h > 0)
output = "#{d} day#{Util.pluralize(d)}, #{h} hour#{Util.pluralize(h)}, #{m} minute#{Util.pluralize(m)}, #{s} second#{Util.pluralize(s)}" if (d > 0)
return output
end
|