Patch #14740

display decimals hours only if fractional

Added by Jérôme BATAILLE almost 9 years ago. Updated over 7 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Time tracking
Target version:-

Description

4 hours could be displayed 4 hours
4.5 hours will still be displayed 4.50 hours

RM_14740_display_hours_decimals_only_if_fractional.diff Magnifier (639 Bytes) Jérôme BATAILLE, 2013-08-21 17:31

RM_14740_display_hours_decimals_only_if_fractional_alternative.diff Magnifier (564 Bytes) Daniel Felix, 2013-08-22 15:27

RM_14740_display_hours_decimals_only_if_fractional_V2.diff Magnifier - new patch (771 Bytes) Jérôme BATAILLE, 2014-06-13 19:09

RM_14740_display_hours_decimals_only_if_fractional_V2_tests.diff Magnifier - the unit tests (1.34 KB) Jérôme BATAILLE, 2014-06-13 19:09

History

#2 Updated by Daniel Felix almost 9 years ago

Hi Jérôme,

what do you think about a shorter notation for this. This would improve the read through. But well, maybe just my opinion. :-)

Maybe this thing could be enhanced to solve the sometimes requested format like 4h 30m instead of 4.5h.

#3 Updated by Jérôme BATAILLE almost 9 years ago

what do you think about a shorter notation for this. This would improve the read through. But well, maybe just my opinion. :-)

Your code enhancement is quite OK for me !

Maybe this thing could be enhanced to solve the sometimes requested format like 4h 30m instead of 4.5h.

Could it have side effects ?
For example, I know that sometimes, we copy samples of data directly from the html page and insert it in an excel file to make sorts and filters. More human readable formats like you propose can be more user friendly, but perhaps it can disturb such operations.
I don't know if in recent Redmine versions, there are still cases where exports miss some informations, that we can get by copying html.

Besides, perhaps the hours display format can be configurable in the user profile, to give the possibility to manage any use case ?

#4 Updated by Jérôme BATAILLE about 8 years ago

Hi Daniel,

In the enhancement you provided there is a little glitch because, you compare 2.0 with hours casted as a string.

Is there is a chance that this patch is integrated to the core ?

#5 Updated by Toshi MARUYAMA about 8 years ago

Jérôme BATAILLE wrote:

Is there is a chance that this patch is integrated to the core ?

Please add tests.
source:trunk/test/unit/lib/redmine/i18n_test.rb

#6 Updated by Jérôme BATAILLE about 8 years ago

Here is a new version that fixes the following case :
Input 5.001
=> 5.00 hours was displayed.

Now it displays 5 hours because hours are rounded to 2 decimals.

The second patch adds comprehensive tests.

To test them alone :
ruby -I"lib:test" test/unit/lib/redmine/i18n_test.rb -n test_localize_hours_truncate_decimals_if_integer
ruby -I"lib:test" test/unit/lib/redmine/i18n_test.rb -n test_localize_negative_hours

#7 Updated by Jérôme BATAILLE over 7 years ago

Now that we have provided a patch for the tests, any chance that this patch is integrated to the core ?

Also available in: Atom PDF