Defect #42172 ยป 42172.patch
lib/redmine/i18n.rb | ||
---|---|---|
94 | 94 | |
95 | 95 |
minutes = (hours * 60).round |
96 | 96 |
if Setting.timespan_format == 'minutes' |
97 |
h, m = minutes.divmod(60) |
|
98 |
"%d:%02d" % [h, m] |
|
97 |
h, m = minutes.abs.divmod(60) |
|
98 |
sign = minutes.negative? ? '-' : '' |
|
99 |
"%s%d:%02d" % [sign, h, m] |
|
99 | 100 |
else |
100 | 101 |
number_with_delimiter(sprintf('%.2f', minutes.fdiv(60)), delimiter: nil) |
101 | 102 |
end |
test/helpers/application_helper_test.rb | ||
---|---|---|
2210 | 2210 |
set_language_if_valid 'en' |
2211 | 2211 | |
2212 | 2212 |
with_settings :timespan_format => 'minutes' do |
2213 |
assert_equal '-0:45', format_hours(-0.75) |
|
2214 |
assert_equal '0:00', format_hours(0) |
|
2213 | 2215 |
assert_equal '0:45', format_hours(0.75) |
2214 | 2216 |
assert_equal '0:45 h', l_hours_short(0.75) |
2215 | 2217 |
assert_equal '0:45 hour', l_hours(0.75) |
2216 | 2218 |
end |
2217 | 2219 |
with_settings :timespan_format => 'decimal' do |
2220 |
assert_equal '-0.75', format_hours(-0.75) |
|
2221 |
assert_equal '0.00', format_hours(0) |
|
2218 | 2222 |
assert_equal '0.75', format_hours(0.75) |
2219 | 2223 |
assert_equal '0.75 h', l_hours_short(0.75) |
2220 | 2224 |
assert_equal '0.75 hour', l_hours(0.75) |