View Single Post
Old 02-26-2011, 10:42 AM   #1
kiwidude
calibre/Sigil 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,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Converting text for a datetime custom column

I'm working on one last (cough) addition to the Goodreads sync plugin before I release it, and that is adding the ability to create an action which sets a datetime custom column using either a value from the Goodreads API xml or the current timestamp. So for instance someone who wants a custom column in Calibre representing the date they last read the book could get that value populated by syncing from their Goodreads shelf.

The bit I would appreciate help with is the datetime parsing, and getting a value in the right format to pass to db.set_custom().

Goodreads will supply values in their xml API that look like this:
Code:
<date_added>Mon Feb 21 03:48:31 -0800 2011</date_added>
<date_updated>Mon Feb 21 03:48:31 -0800 2011</date_updated>
<started_at/>
<read_at/>
Could anyone (and yeah it's probably you chaley as Mr Custom Column ) please tell me:
1. What I need to do to convert a variable holding one of those text dates into a value I could pass to db.set_custom()?
2. What I should pass to use a current timestamp?
3. If I were to call db.get_custom() to compare values before deciding to update, what tricks if any I may need to check for equality?

Many thanks
kiwidude is offline   Reply With Quote