]> jfr.im git - z_archive/twitter.git/blobdiff - twitter/archiver.py
Merge pull request #206 from polm/patch-1
[z_archive/twitter.git] / twitter / archiver.py
index 2e88e47c8a0700462e57c5d133a54ae6bbdaeccb..6f2468a6e03cec1120a88d15bc5bf32a4ba9f20a 100644 (file)
@@ -129,14 +129,18 @@ def save_tweets(filename, tweets):
 
     archive.close()
 
-def format_date(utc, to_localtime=True, isoformat=False):
+def format_date(utc, isoformat=False):
     """Parse Twitter's UTC date into UTC or local time."""
     u = datetime.strptime(utc.replace('+0000','UTC'), '%a %b %d %H:%M:%S %Z %Y')
+    # This is the least painful way I could find to create a non-naive
+    # datetime including a UTC timezone. Alternative suggestions
+    # welcome.
     unew = datetime.combine(u.date(), time(u.time().hour,
         u.time().minute, u.time().second, tzinfo=UTC))
 
-    if to_localtime and _time.timezone != 0:
-        unew = unew.astimezone(Local)
+    # Convert to localtime
+    unew = unew.astimezone(Local)
+
     if isoformat:
         return unew.isoformat()
     else: