View Single Post
Old 10-30-2021, 11:39 AM   #3
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,220
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
Quote:
Originally Posted by Vianney View Post
Hello everyone,

I'm new to this forum so I hope I'm in the good place for this question.

I use the Countpage plugin which displays the number of words of a epub in a custom column called "mots".

What I want to do is to display a fraction of this number in another custom column called "durée" (so I can have the reading time of the book, based on my reading speed)

I read some documentation about the calibre templates and functions and I try a lot, but I can't manage to perform this simple operation. I get an error each time i try.

Can anyone explain to me which syntax to use for this operation?

Thanks you very much

Vianney

I believe this is what you are asking for:

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')
Use the template above on your 'durée' column. The value in red on the first line represents your reading speed in pages/hour. Just change it accordingly.

P.S.: I formatted the result to be more human readable. Ex.: '12.8' becomes '12h 48m'.

Edit: You acctually mentioned words, not pages. But it works just the same. Just use your speed in words/hour.

Last edited by thiago.eec; 10-30-2021 at 12:53 PM. Reason: Clarification
thiago.eec is offline   Reply With Quote