Commit d6d69bec authored by Sriram Karra's avatar Sriram Karra

convert datetime object iso format before sending gc feed

parent 417e52c5
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
## ##
import logging, getopt, re, string, sys, time import logging, getopt, re, string, sys, time
from datetime import datetime
import atom, iso8601 import atom, iso8601
import gdata, gdata.data, gdata.contacts.data, gdata.contacts.client import gdata, gdata.data, gdata.contacts.data, gdata.contacts.client
...@@ -45,7 +46,7 @@ class GCContact(Contact): ...@@ -45,7 +46,7 @@ class GCContact(Contact):
if con_itemid: if con_itemid:
self.set_itemid(self.normalize_gcid(con_itemid)) self.set_itemid(self.normalize_gcid(con_itemid))
else: else:
logging.debug('Potential new GCContact: %s', con.get_name()) logging.debug('Potential new GCContact: %s', con.get_disp_name())
self.set_gce(gce) self.set_gce(gce)
if gce: if gce:
...@@ -774,7 +775,7 @@ class GCContact(Contact): ...@@ -774,7 +775,7 @@ class GCContact(Contact):
if c: if c:
ud = gdata.contacts.data.UserDefinedField() ud = gdata.contacts.data.UserDefinedField()
ud.key = 'created' ud.key = 'created'
ud.value = c ud.value = c.isoformat() if isinstance(c, datetime) else c
gce.user_defined_field.append(ud) gce.user_defined_field.append(ud)
for key, val in self.get_custom().iteritems(): for key, val in self.get_custom().iteritems():
...@@ -783,6 +784,7 @@ class GCContact(Contact): ...@@ -783,6 +784,7 @@ class GCContact(Contact):
if val and not key in ['gids']: if val and not key in ['gids']:
ud = gdata.contacts.data.UserDefinedField() ud = gdata.contacts.data.UserDefinedField()
ud.key = key ud.key = key
val = val.isoformat() if isinstance(val, datetime) else val
ud.value = val ud.value = val
gce.user_defined_field.append(ud) gce.user_defined_field.append(ud)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment