summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2018-09-27 13:44:03 +0200
committerAlessio Caiazza <acaiazza@gitlab.com>2018-10-02 17:08:13 +0200
commitea38e832f0f197c5121504d7e193227d3d9c7867 (patch)
tree83450ab82d52b00fa674a9b95e7724e9967e0972 /app/helpers
parentf976418d128e9f00d6bc6e7eb2862e553e82934c (diff)
downloadgitlab-ce-ea38e832f0f197c5121504d7e193227d3d9c7867.tar.gz
Allow remaining time of scheduled jobs to overflow one day
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/time_helper.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/app/helpers/time_helper.rb b/app/helpers/time_helper.rb
index 94044d7b85e..737ec33b2dd 100644
--- a/app/helpers/time_helper.rb
+++ b/app/helpers/time_helper.rb
@@ -21,9 +21,21 @@ module TimeHelper
"#{from.to_s(:short)} - #{to.to_s(:short)}"
end
- def duration_in_numbers(duration)
- time_format = duration < 1.hour ? "%M:%S" : "%H:%M:%S"
+ def duration_in_numbers(duration_in_seconds, allow_overflow = false)
+ if allow_overflow
+ seconds = duration_in_seconds % 1.minute
+ minutes = (duration_in_seconds / 1.minute) % (1.hour / 1.minute)
+ hours = duration_in_seconds / 1.hour
- Time.at(duration).utc.strftime(time_format)
+ if hours == 0
+ "%02d:%02d" % [minutes, seconds]
+ else
+ "%02d:%02d:%02d" % [hours, minutes, seconds]
+ end
+ else
+ time_format = duration_in_seconds < 1.hour ? "%M:%S" : "%H:%M:%S"
+
+ Time.at(duration_in_seconds).utc.strftime(time_format)
+ end
end
end