Commit 71a3336d authored by Rémy Coutable's avatar Rémy Coutable

Cast duration to integer in `TimeHelper#time_interval_in_words`

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 479814b2
module TimeHelper module TimeHelper
def time_interval_in_words(interval_in_seconds) def time_interval_in_words(interval_in_seconds)
interval_in_seconds = interval_in_seconds.to_i
minutes = interval_in_seconds / 60 minutes = interval_in_seconds / 60
seconds = interval_in_seconds - minutes * 60 seconds = interval_in_seconds - minutes * 60
......
...@@ -5,6 +5,7 @@ describe TimeHelper do ...@@ -5,6 +5,7 @@ describe TimeHelper do
it "returns minutes and seconds" do it "returns minutes and seconds" do
intervals_in_words = { intervals_in_words = {
100 => "1 minute 40 seconds", 100 => "1 minute 40 seconds",
100.32 => "1 minute 40 seconds",
121 => "2 minutes 1 second", 121 => "2 minutes 1 second",
3721 => "62 minutes 1 second", 3721 => "62 minutes 1 second",
0 => "0 seconds" 0 => "0 seconds"
......
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