Patch #14740
opendisplay decimals hours only if fractional
Added by Jérôme BATAILLE over 11 years ago. Updated almost 10 years ago.
0%
Description
4 hours could be displayed 4 hours
4.5 hours will still be displayed 4.50 hours
Files
RM_14740_display_hours_decimals_only_if_fractional.diff (639 Bytes) RM_14740_display_hours_decimals_only_if_fractional.diff | Jérôme BATAILLE, 2013-08-21 17:31 | ||
RM_14740_display_hours_decimals_only_if_fractional_alternative.diff (564 Bytes) RM_14740_display_hours_decimals_only_if_fractional_alternative.diff | Daniel Felix, 2013-08-22 15:27 | ||
RM_14740_display_hours_decimals_only_if_fractional_V2.diff (771 Bytes) RM_14740_display_hours_decimals_only_if_fractional_V2.diff | new patch | Jérôme BATAILLE, 2014-06-13 19:09 | |
RM_14740_display_hours_decimals_only_if_fractional_V2_tests.diff (1.34 KB) RM_14740_display_hours_decimals_only_if_fractional_V2_tests.diff | the unit tests | Jérôme BATAILLE, 2014-06-13 19:09 |
Updated by Jérôme BATAILLE over 11 years ago
- File RM_14740_display_hours_decimals_only_if_fractional.diff RM_14740_display_hours_decimals_only_if_fractional.diff added
here is the patch
Updated by Daniel Felix over 11 years ago
- File RM_14740_display_hours_decimals_only_if_fractional_alternative.diff RM_14740_display_hours_decimals_only_if_fractional_alternative.diff added
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.
Updated by Jérôme BATAILLE over 11 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 ?
Updated by Jérôme BATAILLE over 10 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 ?
Updated by Toshi MARUYAMA over 10 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
Updated by Jérôme BATAILLE over 10 years ago
- File RM_14740_display_hours_decimals_only_if_fractional_V2.diff RM_14740_display_hours_decimals_only_if_fractional_V2.diff added
- File RM_14740_display_hours_decimals_only_if_fractional_V2_tests.diff RM_14740_display_hours_decimals_only_if_fractional_V2_tests.diff added
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
Updated by Jérôme BATAILLE almost 10 years ago
Now that we have provided a patch for the tests, any chance that this patch is integrated to the core ?