diff options
author | Annabel Dunstone <annabel.dunstone@gmail.com> | 2016-07-06 14:00:20 -0500 |
---|---|---|
committer | Annabel Dunstone <annabel.dunstone@gmail.com> | 2016-07-06 14:00:20 -0500 |
commit | e9bd8b615b9a0a88aaf7bcc13f5df73deef74805 (patch) | |
tree | 597d1b0d4da57f697584605cb55830dc63c14b99 | |
parent | 96684317aa56b8754c4762012554b828db4293af (diff) | |
download | gitlab-ce-e9bd8b615b9a0a88aaf7bcc13f5df73deef74805.tar.gz |
Update time format of duration18181-pipeline-duration
-rw-r--r-- | app/helpers/time_helper.rb | 7 | ||||
-rw-r--r-- | app/views/projects/ci/pipelines/_pipeline.html.haml | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/app/helpers/time_helper.rb b/app/helpers/time_helper.rb index b04b0a5114c..d1086025ad5 100644 --- a/app/helpers/time_helper.rb +++ b/app/helpers/time_helper.rb @@ -23,4 +23,11 @@ module TimeHelper def date_from_to(from, to) "#{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 < 3600 ? "%M:%S" : "%H:%M:%S" + + Time.at(diff_in_seconds).utc.strftime(time_format) + end end diff --git a/app/views/projects/ci/pipelines/_pipeline.html.haml b/app/views/projects/ci/pipelines/_pipeline.html.haml index e38d1ff5ff0..af8dd5cd02c 100644 --- a/app/views/projects/ci/pipelines/_pipeline.html.haml +++ b/app/views/projects/ci/pipelines/_pipeline.html.haml @@ -45,7 +45,7 @@ %td - if pipeline.started_at && pipeline.finished_at %p.duration - #{duration_in_words(pipeline.finished_at, pipeline.started_at)} + = duration_in_numbers(pipeline.finished_at, pipeline.started_at) %td .controls.hidden-xs.pull-right |