Defect #42172 ยป 42172.patch
| lib/redmine/i18n.rb | ||
|---|---|---|
|
minutes = (hours * 60).round
|
||
|
if Setting.timespan_format == 'minutes'
|
||
|
h, m = minutes.divmod(60)
|
||
|
"%d:%02d" % [h, m]
|
||
|
h, m = minutes.abs.divmod(60)
|
||
|
sign = minutes.negative? ? '-' : ''
|
||
|
"%s%d:%02d" % [sign, h, m]
|
||
|
else
|
||
|
number_with_delimiter(sprintf('%.2f', minutes.fdiv(60)), delimiter: nil)
|
||
|
end
|
||
| test/helpers/application_helper_test.rb | ||
|---|---|---|
|
set_language_if_valid 'en'
|
||
|
with_settings :timespan_format => 'minutes' do
|
||
|
assert_equal '-0:45', format_hours(-0.75)
|
||
|
assert_equal '0:00', format_hours(0)
|
||
|
assert_equal '0:45', format_hours(0.75)
|
||
|
assert_equal '0:45 h', l_hours_short(0.75)
|
||
|
assert_equal '0:45 hour', l_hours(0.75)
|
||
|
end
|
||
|
with_settings :timespan_format => 'decimal' do
|
||
|
assert_equal '-0.75', format_hours(-0.75)
|
||
|
assert_equal '0.00', format_hours(0)
|
||
|
assert_equal '0.75', format_hours(0.75)
|
||
|
assert_equal '0.75 h', l_hours_short(0.75)
|
||
|
assert_equal '0.75 hour', l_hours(0.75)
|
||