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 ...@@ -27,11 +27,7 @@ module TimeHelper
minutes = (duration_in_seconds / 1.minute) % (1.hour / 1.minute) minutes = (duration_in_seconds / 1.minute) % (1.hour / 1.minute)
hours = duration_in_seconds / 1.hour hours = duration_in_seconds / 1.hour
if hours == 0
"%02d:%02d" % [minutes, seconds]
else
"%02d:%02d:%02d" % [hours, minutes, seconds] "%02d:%02d:%02d" % [hours, minutes, seconds]
end
else else
time_format = duration_in_seconds < 1.hour ? "%M:%S" : "%H:%M:%S" time_format = duration_in_seconds < 1.hour ? "%M:%S" : "%H:%M:%S"
......
...@@ -39,10 +39,10 @@ describe TimeHelper do ...@@ -39,10 +39,10 @@ describe TimeHelper do
context "with allow_overflow = true" do context "with allow_overflow = true" do
where(:duration, :formatted_string) do where(:duration, :formatted_string) do
0 | "00:00" 0 | "00:00:00"
1.second | "00:01" 1.second | "00:00:01"
42.seconds | "00:42" 42.seconds | "00:00:42"
2.minutes + 1.second | "02:01" 2.minutes + 1.second | "00:02:01"
3.hours + 2.minutes + 1.second | "03:02:01" 3.hours + 2.minutes + 1.second | "03:02:01"
30.hours | "30:00:00" 30.hours | "30:00:00"
end 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