mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
use elegant code suggested in https://github.com/opf/openproject/pull/18583#discussion_r2046954108
This commit is contained in:
@@ -197,13 +197,7 @@ module ChronicDuration
|
||||
# Pad zeros on minutes
|
||||
divider = ":"
|
||||
result = str.split(divider).each_with_index.map do |n, index|
|
||||
if index > 0 && n.length == 1
|
||||
"0#{n}"
|
||||
elsif index > 0 && n.empty?
|
||||
"00"
|
||||
else
|
||||
n
|
||||
end
|
||||
n.rjust(index > 0 ? 2 : 1, "0")
|
||||
end.join(divider)
|
||||
"#{result} h"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user