Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 06-14-2016, 09:59 PM   #1
Pyjam
Zealot
Pyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead community
 
Posts: 143
Karma: 15920
Join Date: Aug 2015
Device: Kindle Voyage
Question 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.
Pyjam is offline   Reply With Quote
Old 06-15-2016, 04:36 AM   #2
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,583
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by Pyjam View Post
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.
@Pyjam - I have this for video duration, I think you'd need 'hh mm' in the format.

Click image for larger version

Name:	Clipboard01.jpg
Views:	153
Size:	23.3 KB
ID:	149419

BR
BetterRed is online now   Reply With Quote
Advert
Old 06-15-2016, 05:10 AM   #3
Pyjam
Zealot
Pyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead community
 
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.
Pyjam is offline   Reply With Quote
Old 06-15-2016, 05:50 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Pyjam View Post
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.
What you want to do pushes the template language to its limits. It isn't designed to do complicated floating point arithmetic such as floor and round, and it doesn't have the notion of "duration".

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}'))
For template function documentation see Reference for all built-in template language functions
chaley is offline   Reply With Quote
Old 06-15-2016, 05:58 AM   #5
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
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
BetterRed is online now   Reply With Quote
Advert
Old 06-15-2016, 06:45 AM   #6
Pyjam
Zealot
Pyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead community
 
Posts: 143
Karma: 15920
Join Date: Aug 2015
Device: Kindle Voyage
Thanks for your help.

Unfortunately, the columns show the formulae, not the values!
Pyjam is offline   Reply With Quote
Old 06-15-2016, 06:51 AM   #7
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Pyjam View Post
Thanks for your help.

Unfortunately, the columns show the formulae, not the values!
Then you have not entered the template correctly.

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.
Attached Thumbnails
Click image for larger version

Name:	Clipboard01.png
Views:	140
Size:	25.2 KB
ID:	149421  
chaley is offline   Reply With Quote
Old 06-15-2016, 07:02 AM   #8
Pyjam
Zealot
Pyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead communityPyjam has become a pillar of the MobileRead community
 
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.
Pyjam is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 07:33 AM.


MobileRead.com is a privately owned, operated and funded community.