Commit 786ae683 authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Alessio Caiazza

Do not omit leading zeros in duration_in_numbers helper

parent 6369ff1c
......@@ -27,11 +27,7 @@ module TimeHelper
minutes = (duration_in_seconds / 1.minute) % (1.hour / 1.minute)
hours = duration_in_seconds / 1.hour
if hours == 0
"%02d:%02d" % [minutes, seconds]
else
"%02d:%02d:%02d" % [hours, minutes, seconds]
end
"%02d:%02d:%02d" % [hours, minutes, seconds]
else
time_format = duration_in_seconds < 1.hour ? "%M:%S" : "%H:%M:%S"
......
......@@ -39,10 +39,10 @@ describe TimeHelper do
context "with allow_overflow = true" do
where(:duration, :formatted_string) do
0 | "00:00"
1.second | "00:01"
42.seconds | "00:42"
2.minutes + 1.second | "02:01"
0 | "00:00:00"
1.second | "00:00:01"
42.seconds | "00:00:42"
2.minutes + 1.second | "00:02:01"
3.hours + 2.minutes + 1.second | "03:02:01"
30.hours | "30:00:00"
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment