06-14-2016, 09:59 PM | #1 |
Zealot
Posts: 143
Karma: 15920
Join Date: Aug 2015
Device: Kindle Voyage
|
Calculated duration
I would like to add a column: a duration (format h:mm) that is the number of words (#words) divided by 300 in minutes.
Could you help me. Thank you. |
06-15-2016, 04:36 AM | #2 | |
null operator (he/him)
Posts: 20,583
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
BR |
|
Advert | |
|
06-15-2016, 05:10 AM | #3 |
Zealot
Posts: 143
Karma: 15920
Join Date: Aug 2015
Device: Kindle Voyage
|
Thanks for your help. I have two problems:
1) When a column is based upon another column, I see no place where to input a specific format. 2) I don't know the formula for the the division and the conversion of type. |
06-15-2016, 05:50 AM | #4 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
That said, the following General Program Mode (GPM) template works for me. Since we don't have the duration type we must calculate the parts manually. Since we don't have the "floor" function, the template does the equivalent with string processing to chop off the fractional part from "hours". Fortuitously the number formatter does rounding so we don't need to do that manually when calculating the total minutes as an integer. Code:
program: total = format_number(divide(raw_field('#words'), 300), '{0:.0f}'); hours = re(divide(total, 60), '\..*', ''); minutes = subtract(total, multiply(hours, 60)); strcat(hours, ':', format_number(minutes, '{0:02d}')) |
|
06-15-2016, 05:58 AM | #5 |
null operator (he/him)
Posts: 20,583
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
↑ ↑ ↑ ↑ - wot 'e sed
@Pyjam - aaah - you'll need to use the template language, see ==>> The calibre template language Template language is not something in which I have much expertise. I can give some hints though. I would try doing the arithmetic to get hours and minutes as two discrete integers using then divide function, and then use the format-number and strcat functions to create a string that is the column value. BR Last edited by BetterRed; 06-15-2016 at 06:01 AM. Reason: Ninja'd by the expert |
Advert | |
|
06-15-2016, 06:45 AM | #6 |
Zealot
Posts: 143
Karma: 15920
Join Date: Aug 2015
Device: Kindle Voyage
|
Thanks for your help.
Unfortunately, the columns show the formulae, not the values! |
06-15-2016, 06:51 AM | #7 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
The easiest way to edit composite column (column built from other columns) templates is to edit them on the main book list. Click on any cell in the composite column, press F2 (or whatever Edit is on your OS), and paste the template into the resulting editor. |
|
06-15-2016, 07:02 AM | #8 |
Zealot
Posts: 143
Karma: 15920
Join Date: Aug 2015
Device: Kindle Voyage
|
Thanks for your patience. I'd not understood: I'd created separate columns for total, hours, minutes, and final result.
It works very well now. Thank you. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mesure battery duration for KSM | embryo | Kobo Developer's Corner | 11 | 09-21-2017 04:00 PM |
Classic Bettery duration | milan | Barnes & Noble NOOK | 42 | 09-02-2010 01:01 AM |
iPad What battery duration do you experience? | mgmueller | Apple Devices | 29 | 06-03-2010 05:25 PM |
Duration of copyright poll. | Trenien | News | 159 | 07-23-2008 05:28 PM |
Iliad battery duration is better? | fdojose | iRex | 1 | 02-08-2008 02:37 PM |