Quote:
Originally Posted by thiago.eec
Code:
program:
reading_time = divide(raw_field('#mots'), 50);
h = format_number(subtract(reading_time, fractional_part(reading_time)), '{0:0>2.0f}');
m = format_number(multiply(fractional_part(reading_time), 60), '{0:0>2.0f}');
reading_time = strcat(h, 'h ', m, 'm')
|
And just for fun, using the recent changes to the template language:
Code:
program:
reading_time = (if $$#mots == 'none' then 0 else $$#myfloat fi) / 50;
h = format_number(floor(reading_time), '{0:0>2.0f}');
m = format_number(fractional_part(reading_time) * 60, '{0:0>2.0f}');
reading_time = strcat(h, 'h ', m, 'm')
The strange 'if' on line 2 is there because I found a bug in calculating binary operators like '/'. Undefined raw fields don't work. I will fix that. After I fix it the line would be
Code:
reading_time = $$#mots / 50;