07-25-2020, 06:26 PM | #1 |
Member
Posts: 19
Karma: 34258
Join Date: Jul 2020
Device: Kobo Libra H2O
|
Custom Column - How Long to Read
I've got Calibre showing page and word counts, I'd like to have a custom column that reads the word count, divides by reading speed, then divides by 60 to produce a value in hours and minutes.
I've looked through the template language doc but I'm lost, can anyone please help me out? |
07-25-2020, 08:18 PM | #2 | |
Resident Curmudgeon
Posts: 74,196
Karma: 129333564
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
Advert | |
|
07-26-2020, 12:31 AM | #3 |
Grand Sorcerer
Posts: 24,906
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Something like the following is what you want:
Code:
program: format_number(divide(divide(raw_field('#words'),1000),60), '{0:5,.2f}') The formatting will give the number with two decimal points. |
07-28-2020, 03:57 PM | #4 |
Member
Posts: 19
Karma: 34258
Join Date: Jul 2020
Device: Kobo Libra H2O
|
Thank you both, again.
I couldn't figure out where the code goes, tried custom columns and template functions but the code itself appears in the column. No bother, I can use word the count to give me an idea. |
07-29-2020, 05:46 AM | #5 |
Grand Sorcerer
Posts: 24,906
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
It is the template for a custom column of type "Column built from other columns". Put all of the code that I posted into that. This include the "program:".
|
Advert | |
|
07-29-2020, 06:05 AM | #6 |
Resident Curmudgeon
Posts: 74,196
Karma: 129333564
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
If you use the Kobo time count, you can figure out your reading speed and use that to get a more accurate result. I suggest at least 5 times.
|
07-29-2020, 06:19 AM | #7 |
Wizard
Posts: 1,674
Karma: 3111989
Join Date: Dec 2010
Location: Jianghu
Device: PW1, PW5, iPhone SE 2016, iPhone 13 Pro, iPad Pro 9.7, iPad Pro 2021
|
|
07-29-2020, 06:49 AM | #8 | |
Grand Sorcerer
Posts: 24,906
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
The instructions for adding custom column with a template are in Techniques to use plugboards, custom columns and templates. |
|
07-29-2020, 07:34 PM | #9 | |
Member
Posts: 15
Karma: 10
Join Date: Jul 2020
Device: none
|
Quote:
EDIT: Now I see numbers like 1.86 so im guessing not hours/minutes. Anyway to convert? Last edited by kcar181; 07-29-2020 at 07:50 PM. |
|
07-29-2020, 07:55 PM | #10 | |
Custom User Title
Posts: 8,677
Karma: 61664305
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Quote:
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. Last edited by ownedbycats; 07-29-2020 at 08:04 PM. |
|
07-29-2020, 08:08 PM | #11 |
Member
Posts: 15
Karma: 10
Join Date: Jul 2020
Device: none
|
Ok so if id like just minutes im guessing this would do the trick
Code:
program: format_number(multiply(divide(divide(raw_field('#chars'),310),60),60), '{0:5,.2f}') EDIT: Ok learning something new. So I think 1.86 would be a decimal hour so 1 hour and 86/100 of an hour. Last edited by kcar181; 07-29-2020 at 08:18 PM. |
07-29-2020, 08:40 PM | #12 | |
Wizard
Posts: 1,674
Karma: 3111989
Join Date: Dec 2010
Location: Jianghu
Device: PW1, PW5, iPhone SE 2016, iPhone 13 Pro, iPad Pro 9.7, iPad Pro 2021
|
Quote:
Anyway, it works now |
|
07-30-2020, 06:47 AM | #13 | |
Grand Sorcerer
Posts: 11,748
Karma: 7029855
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
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')) |
|
07-30-2020, 08:58 AM | #14 |
Grand Sorcerer
Posts: 24,906
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
And here was me thinking of doing:
Code:
program: minutes = divide(raw_field('#words'),310); hours = divide(minutes, 60); hours = list_item(hours,0,'.'); minutes = subtract(minutes, multiply(hours,60)); minutes = format_number(minutes, '02,.0f'); strcat(hours,':',minutes) But, I've wanted some of your new functions before. So, I'm happy to see them. |
07-30-2020, 09:12 AM | #15 |
Member
Posts: 19
Karma: 34258
Join Date: Jul 2020
Device: Kobo Libra H2O
|
I missed out the 'program:' in mine as well, got it working now.
Really appreciate everyone's input! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Browser Viewer: Long-text Custom Column | nqk | Server | 8 | 08-05-2018 08:25 AM |
Custom column long text toolbar | MerlinMama | Calibre | 2 | 03-01-2017 01:14 PM |
Creating Custom Column for Read and Date Read | library addict | Calibre Companion | 11 | 03-22-2014 05:33 AM |
Custom yes/no column built from long text column | Philantrop | Library Management | 7 | 03-23-2013 07:44 PM |
No search/replace on custom long text column? | CWatkinsNash | Library Management | 2 | 06-20-2011 05:57 PM |