puzzle-scoreboard/app/helpers/contests_helper.rb
sto 9862f0c74b
All checks were successful
CI / scan_ruby (push) Successful in 18s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 39s
Relative times: pad to minutes format
2025-06-26 10:56:09 +02:00

21 lines
349 B
Ruby

module ContestsHelper
def pad(n)
if n > 9
return n.to_s
end
"0" + n.to_s
end
def display_time(time)
h = time / 3600
m = (time % 3600) / 60
s = (time % 3600) % 60
if h > 0
return h.to_s + ":" + pad(m) + ":" + pad(s)
elsif m > 0
return m.to_s + ":" + pad(s)
end
"0:" + pad(s)
end
end