X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fbackends%2Fgvoice.py;fp=src%2Fbackends%2Fgvoice.py;h=59528537138ac99581b06bdc8502c9105d4ed440;hb=d5c38af48e9f9d2e5f0e06a3d03d16b8dd9800c7;hp=e9dff9883c633b1278986d3211fe2f4070f68442;hpb=9a8f65b5118f73756260e6144450f6273d3ee0ee;p=gc-dialer diff --git a/src/backends/gvoice.py b/src/backends/gvoice.py index e9dff98..5952853 100755 --- a/src/backends/gvoice.py +++ b/src/backends/gvoice.py @@ -557,7 +557,7 @@ class GVoiceBackend(object): for messageId, messageHtml in itergroup(splitVoicemail[1:], 2): exactTimeGroup = self._exactVoicemailTimeRegex.search(messageHtml) exactTime = exactTimeGroup.group(1).strip() if exactTimeGroup else "" - exactTime = datetime.datetime.strptime(exactTime, "%m/%d/%y %I:%M %p") + exactTime = google_strptime(exactTime) relativeTimeGroup = self._relativeVoicemailTimeRegex.search(messageHtml) relativeTime = relativeTimeGroup.group(1).strip() if relativeTimeGroup else "" locationGroup = self._voicemailLocationRegex.search(messageHtml) @@ -605,7 +605,7 @@ class GVoiceBackend(object): exactTimeGroup = self._exactVoicemailTimeRegex.search(messageHtml) exactTimeText = exactTimeGroup.group(1).strip() if exactTimeGroup else "" - conv.time = datetime.datetime.strptime(exactTimeText, "%m/%d/%y %I:%M %p") + conv.time = google_strptime(exactTimeText) relativeTimeGroup = self._relativeVoicemailTimeRegex.search(messageHtml) conv.relTime = relativeTimeGroup.group(1).strip() if relativeTimeGroup else "" locationGroup = self._voicemailLocationRegex.search(messageHtml) @@ -655,7 +655,7 @@ class GVoiceBackend(object): exactTimeGroup = self._exactVoicemailTimeRegex.search(messageHtml) exactTimeText = exactTimeGroup.group(1).strip() if exactTimeGroup else "" - conv.time = datetime.datetime.strptime(exactTimeText, "%m/%d/%y %I:%M %p") + conv.time = google_strptime(exactTimeText) relativeTimeGroup = self._relativeVoicemailTimeRegex.search(messageHtml) conv.relTime = relativeTimeGroup.group(1).strip() if relativeTimeGroup else "" conv.location = "" @@ -722,6 +722,19 @@ class GVoiceBackend(object): return json +def google_strptime(time): + """ + Hack: Google always returns the time in the same locale. Sadly if the + local system's locale is different, there isn't a way to perfectly handle + the time. So instead we handle implement some time formatting + """ + abbrevTime = time[:-3] + parsedTime = datetime.datetime.strptime(abbrevTime, "%m/%d/%y %I:%M") + if time[-2] == "PN": + parsedTime += datetime.timedelta(hours=12) + return parsedTime + + def itergroup(iterator, count, padValue = None): """ Iterate in groups of 'count' values. If there