Commits

Peter Sanchez  committed 1c366d7

Updated for stupid MySQL timezone issue.

  • Participants
  • Parent commits 0d5e3a6

Comments (0)

Files changed (2)

File twittersync/__init__.py

-__version__ = '0.3'
+__version__ = '0.4'

File twittersync/helpers.py

 
         return opener.open(self.build_url(qdict))
 
+    def _get_proper_date(self, c_date):
+        ''' Stupid helper to work around MySQL not able to 
+            handle timezones.
+            Ref: https://docs.djangoproject.com/en/1.3/ref/databases/#datetime-fields
+            XXX: Find a proper fix! Maybe just catch ValueError ?
+        '''
+        dbs = [x['ENGINE'].split('.')[-1] for x in settings.DATABASES.values()]
+        if 'mysql' in dbs:
+            return datatime.datetime.now()
+        return c_date
+
     def save_status_update(self, result):
         return TwitterStatus.objects.get_or_create(
             status_id=result['id_str'],
             author=self.account,
             content=result['text'],
-            created_date=parse(result['created_at']),
+            created_date=self._get_proper_date(parse(result['created_at'])),
         )
 
     def sync_twitter_account(self):