Originally Posted by kiwidude
I'm working on one last (cough) addition to the Goodreads sync plugin before I release it
Goodreads will supply values in their xml API that look like this:
Could anyone (and yeah it's probably you chaley as Mr Custom Column ) please tell me:
<date_added>Mon Feb 21 03:48:31 -0800 2011</date_added>
<date_updated>Mon Feb 21 03:48:31 -0800 2011</date_updated>
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?
I think the following sample answers all three questions.
from calibre.utils.date import parse_date, now
dt1 = parse_date("Mon Feb 21 03:48:31 -0800 2011")
dt2 = now()
print 'dt1 == dt1', dt1 == dt1
print 'dt1 == dt2', dt1 == dt2
print 'dt1 < dt2', dt1 < dt2
print 'dt1 > dt2', dt1 > dt2
print 'dt2 == dt2', dt2 == dt2
C:\CBH_Data\calibre_development>calibre-debug -e foo2.py
dt1 == dt1 True
dt1 == dt2 False
dt1 < dt2 True
dt1 > dt2 False
dt2 == dt2 True