Quote:
Originally Posted by chaley
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.
|
For me, I've only once had a reading time go over 17 hours (and that was an omnibus with over 1 million words).
OTOH, your new function looks good for some of my other uses and is much appreciated compared to my current multi-line mess for converting seconds to other time units.
Edit: downloaded calibre source and the format_duration seems to be working okay for me where a book has been opened to read. I still need to play handling entries where the book has not been opened.