UTC encode datetime in results.csv master
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Mon, 18 Feb 2013 23:32:29 +0000 (23:32 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Mon, 18 Feb 2013 23:32:29 +0000 (23:32 +0000)
members.py

index 87b3876cb61735610a0680acec41c811ead247f0..27026349ece9dc1ab298b6706f4df3b4e4a80f9d 100755 (executable)
@@ -8,7 +8,7 @@ import os
 import time
 import re
 import logging
-from datetime import datetime
+from datetime import datetime, tzinfo, timedelta
 import calendar
 import random
 import urllib.request
@@ -51,6 +51,22 @@ Note that in last 2 FLOOD lines exemple, NewField1 is 102 that is different from
 #PASSWORD
 #BASE_URL
 DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
+TIMEDELTA0 = timedelta(0)
+
+class Utc(tzinfo):
+    """UTC"""
+
+    def utcoffset(self, dt):
+        return TIMEDELTA0
+
+    def tzname(self, dt):
+        return "UTC"
+
+    def dst(self, dt):
+        return TIMEDELTA0
+
+UTC = Utc()
+
 
 USER_AGENT="Mozilla/5.0 (X11; U; Linux.i686; en-US; rv:1.9.1.16) Gecko/20121020 Iceweasel/3.5.16 (like Firefox/3.5.16)"
 
@@ -274,7 +290,7 @@ def publish_line(csvfile, text, **args):
     csvline = text.format(**args)
     logging.info(csvline.split(',')[-1])
     if not options.dryrun:
-        csvfile.write(time.strftime(DATETIME_FORMAT)+','+csvline+'\n')
+        csvfile.write(datetime.now(UTC).strftime(DATETIME_FORMAT)+','+csvline+'\n')
 
 def field_compare(oldmembers, newmembers, csvfile):