diff options
author | Phil Hughes <me@iamphill.com> | 2016-08-30 10:43:09 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-08-30 10:43:09 +0100 |
commit | 85f6244ce852fb6b788ea660c7d0cbe14ec10a20 (patch) | |
tree | ec29f6c01ea8e4ac774f3dae874a3a3abf97267b /app/helpers/time_helper.rb | |
parent | 2bee8e7db927d2bc2c5912b98dfe52d3c3c40fbd (diff) | |
parent | 2778dec131c2afac9fcdb2c42365b69099a5ae5b (diff) | |
download | gitlab-ce-85f6244ce852fb6b788ea660c7d0cbe14ec10a20.tar.gz |
Merge branch 'master' into build-cancel-spinner
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 |