Quote:
Originally Posted by ownedbycats
Multiply by 60 to get the number of minutes.
For 2.29 hours that's ~137 minutes.
Divide that by sixty again using whole numbers and the remainder is 17 minutes.
You end up with 2:17. 
|
Unfortunately you currently can't do that calculation in the template language. All the arithmetic is floating point.
I am going to add some more math functions: floor(x), ceiling(x), fractional_part(x), round(x), and mod(x, y). Using these (when they are released), you will be able to compute hours:minutes from fractional hours using something like this template.
Code:
program:
# total_hours should be a field reference
fractional_hours = 3.6982;
# Compute the number of hours in total minutes as an integer
display_hours = floor(fractional_hours );
# Compute the number of minutes left over after display_hours
display_mins = round(multiply(fractional_part(fractional_hours ), 60));
# Format the results as h:mm
strcat(display_hours, ':', format_number(display_mins, '02d'))
This template produces the result "3:42"