12-16-2011, 10:54 AM | #1 |
Addict
Posts: 288
Karma: 1003542
Join Date: May 2011
Device: Google Nexus 7 16GB
|
Time Column
I'm wondering what the options are when making a custom column for "Time"
Ideally it would be like the Date selector, where a calendar is available to quick select, but I imagine that's not possible for time. So is there a nice way to display and/or enter time in a column I have been looking at the python number formatting strings, but its too full of unfamiliar terms for me to understand. usage will mostly be for small time increments below 4 hours and probably consisting of lots of mins. ie 1h 30min, 45min, 1h 15min, that kind of thing, if it makes a difference. I did notice that the up/down arrows seem only to change whole integers, wondering if that is set or can be changed... anyway if anyone has any thoughts on time entry please let me know. |
12-16-2011, 11:19 AM | #2 | |
Well trained by Cats
Posts: 29,689
Karma: 54369090
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Look in the (save to disk) template editor: format_modtimes for code clues |
|
Advert | |
|
12-16-2011, 12:47 PM | #3 |
Addict
Posts: 288
Karma: 1003542
Join Date: May 2011
Device: Google Nexus 7 16GB
|
thanks for helping Ducks,
But really this... def evaluate(self, formatter, kwargs, mi, locals, fmt): fmt_data = mi.get('format_metadata', {}) data = sorted(fmt_data.items(), key=lambda x:x[1]['mtime'], reverse=True) return ','.join(k.upper()+':'+format_date(v['mtime'], fmt) for k,v in data) Means nothing to me I just really want to know what to put in here - see attachment. |
12-17-2011, 03:07 PM | #4 |
Addict
Posts: 288
Karma: 1003542
Join Date: May 2011
Device: Google Nexus 7 16GB
|
Still Stuck on this, is anyone able to help me make a simple time column?
Would be very grateful. PS, I did try and find out answer myself, but then I took an arrow in the knee. |
12-18-2011, 03:32 AM | #5 |
Grand Sorcerer
Posts: 11,703
Karma: 6658935
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
It seems that you want a column to express duration in minutes, not a time. I can think of one way to do this, but it isn't particularly pretty.
First: what doesn't work. Using the formatting feature of float and integer doesn't work because you cannot separate the number into the two hours/minutes components. Using a datetime with a format of "hh:mm" doesn't work because it isn't a duration; the rest of the date will be set to something, making the column not sortable. What does work is to use a custom integer field to enter the number of minutes, and then use a custom composite field and a custom template function to format that number-of-minutes into hours and minutes. One possible template function is Code:
Function: myHoursMinutes Arg count: 1 Program code: def evaluate(self, formatter, kwargs, mi, locals, x): if not x: return '' r = int(x) return "%d h %d min"%(r/60, r%60) Code:
{#myint:myHoursMinutes()} |
Advert | |
|
12-18-2011, 04:53 PM | #6 |
Addict
Posts: 288
Karma: 1003542
Join Date: May 2011
Device: Google Nexus 7 16GB
|
Thanks chaley,
Yep your right, keeping it simple is better, and while I liked your suggestion I decided to forgo some sorting capability's and use a (Oh hang on they do sort in order of duration - weird) text field. So went with this - and as bonus colour was an option, so longer gets redder. Thanks all for your help, can get back to skyrim now, er I mean back to finding out if I can use calibre to store and index my recipes |
Tags |
time |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
2 column PDF book to 1 column possible? | SeaBookGuy | Calibre | 19 | 07-01-2013 02:30 AM |
Column copy (one time) | wsignal | Library Management | 6 | 05-08-2013 04:41 PM |
Q: multi-column PDF to single column mobi format converstion | auburn1975 | Calibre | 7 | 01-28-2012 06:11 PM |
anyway to change 2 column lrf to 1 column mobi? | lapisjay | Amazon Kindle | 2 | 01-12-2011 10:20 PM |
pdf to lrf with 2 column and 1 column pages in same file | danielwille | Sony Reader | 3 | 11-12-2008 10:57 AM |