Commit 1676fa00 authored by Sriram Karra's avatar Sriram Karra

Support more iso date formats in vCard revision strings

This fixes https://github.com/skarra/ASynK/issues/48

OwnCloud uses a different format string for revision strings
than what we have seen with other CardDAV servers. To their
credit the format is a iso8601 parseable string. Let's just
parse them
parent a513bf0e
......@@ -362,6 +362,11 @@ class CDContact(Contact):
else:
dt = pimdb_cd.CDPIMDB.parse_vcard_time("19800101T000000Z")
if dt is None:
logging.error(('Could not parse revision string (%s) for %s.' +
'This may result in improper sync.'),
vco.rev.value, self.get_name())
self.set_updated(dt)
## Date of Birth
......
......@@ -30,6 +30,7 @@ from caldavclientlibrary.protocol.http.util import HTTPError
from caldavclientlibrary.protocol.url import URL
from caldavclientlibrary.client.account import CalDAVAccount
import iso8601
import datetime, logging, os, re, sys, urllib, urlparse
class CardDAVPrincipalNotFoundError(Exception):
......@@ -128,6 +129,8 @@ class CDPIMDB(PIMDB):
## def_adbk_url property request. In this case we will just pick
## the first folder. One hopes every addressbook server will have
## at least one server
logging.debug('Coud not find default adbk Property. Trying to ' +
'use first of the available contacts folders')
fs = self.get_contacts_folders()
assert(len(fs) > 0)
def_f = fs[0]
......@@ -194,10 +197,10 @@ class CDPIMDB(PIMDB):
res = re.search(r'(\d\d\d\d\d\d\d\dT\d\d\d\d\d\dZ).*', t)
if res:
t = res.group(1)
return datetime.datetime.strptime(t, '%Y%m%dT%H%M%SZ')
else:
return None
return datetime.datetime.strptime(t, '%Y%m%dT%H%M%SZ')
t = iso8601.parse(t)
return datetime.datetime.utcfromtimestamp(t)
## Note: I learnt of the setter, and @property and @property.setter
## decorations well after I started developing ASynK. So for the sake of
......
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