diff options
Diffstat (limited to 'app/helpers/time_helper.rb')
-rw-r--r-- | app/helpers/time_helper.rb | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/app/helpers/time_helper.rb b/app/helpers/time_helper.rb index 8cb82c2d5cc..271e839692a 100644 --- a/app/helpers/time_helper.rb +++ b/app/helpers/time_helper.rb @@ -1,15 +1,6 @@ module TimeHelper - def duration_in_words(finished_at, started_at) - if finished_at && started_at - interval_in_seconds = finished_at.to_i - started_at.to_i - elsif started_at - interval_in_seconds = Time.now.to_i - started_at.to_i - end - - time_interval_in_words(interval_in_seconds) - end - def time_interval_in_words(interval_in_seconds) + interval_in_seconds = interval_in_seconds.to_i minutes = interval_in_seconds / 60 seconds = interval_in_seconds - minutes * 60 @@ -24,10 +15,9 @@ module TimeHelper "#{from.to_s(:short)} - #{to.to_s(:short)}" end - def duration_in_numbers(finished_at, started_at) - diff_in_seconds = finished_at.to_i - started_at.to_i - time_format = diff_in_seconds < 1.hour ? "%M:%S" : "%H:%M:%S" + def duration_in_numbers(duration) + time_format = duration < 1.hour ? "%M:%S" : "%H:%M:%S" - Time.at(diff_in_seconds).utc.strftime(time_format) + Time.at(duration).utc.strftime(time_format) end end |