Quote:
Originally Posted by DNSB
As @chaley said, it would help if you posted what you used as the template and the column definition.
For what it may be worth, here's my variant which gives hours, minutes, seconds:
Code:
program:
total = $#kobo_time_spent_reading;
hours = floor(total/3600);
minutes = floor(mod(total, 3600)/60);
seconds = mod(total, 60);
def format(v, str):
if v == 0 then return '' fi;
return v & ' ' & str & ' '
fed;
format(hours, 'hr') & format(minutes, 'min') & format(seconds, 'sec')
|
FWIW: I've seen several posts over the years that discuss formatting a duration in seconds into some "human readable" string. I decided to add a template function
Code:
format_duration(value, template, largest_unit)
that given a duration is seconds can produce things like "2 weeks 4 days 20 minutes". I'll post the documentation in the template changes thread if and when Kovid accepts the change.