View Single Post
Old 12-14-2011, 06:20 PM   #1
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Working with DateTime custom columns programmatically?

I'm working on a new version of my Goodreads Sync plugin, and I need to do something I haven't done before of working with datetime custom columns.

1. Assume I get the Metadata object for a book, using mi = db.get_metadata(book_id, index_is_id=True). And lets say I know the custom column is called '#dateread'. When I query the value using this:

dateread = mi.get('#dateread')

I end up with this text value in my variable:
datetime.datetime(2011, 12, 14, 22, 50, 50, tzinfo=SafeLocalTimeZone())

So that presumes there has to be some sort of further manipulation of this to get it into an actual date time value. And presumably this may also need to take into account the format associated with the custom column?

Which leads on to the next question...

2. The point of retrieving this date, is to allow it to be edited as a cell within my QTableWidget. Is there either a cell widget I can reuse for editing dates or any other pointers on an alternative? Depending on whether there is, and what input it requires (a datetime object or a string) will perhaps help dictate the answer to question 1 in terms of what to retrieve the value of that custom column as.

Thanks...
kiwidude is offline   Reply With Quote