[Pywikipedia-l] SVN: [5993] trunk/pywikipedia/checkimages.py

nicdumz at svn.wikimedia.org nicdumz at svn.wikimedia.org
Sat Oct 18 16:02:00 UTC 2008


Revision: 5993
Author:   nicdumz
Date:     2008-10-18 16:02:00 +0000 (Sat, 18 Oct 2008)

Log Message:
-----------
UTC-absolute time calculations

Modified Paths:
--------------
    trunk/pywikipedia/checkimages.py

Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py	2008-10-18 15:26:39 UTC (rev 5992)
+++ trunk/pywikipedia/checkimages.py	2008-10-18 16:02:00 UTC (rev 5993)
@@ -83,6 +83,7 @@
 
 import re, time, urllib, urllib2, os, locale, sys
 import wikipedia, config, pagegenerators, catlib, query
+from datetime import datetime
 
 locale.setlocale(locale.LC_ALL, '')
 
@@ -1164,13 +1165,11 @@
             first x seconds.
         """
         imagedata = self.image.getLatestUploader()[1]
-        os.environ['TZ'] = 'EST+01EDT,M4.1.0,M10.5.0'
-        time.tzset()
         # '2008-06-18T08:04:29Z'
-        data = time.strptime(imagedata, u"%Y-%m-%dT%H:%M:%SZ")
-        data_seconds = time.mktime(data)
-        current_time = time.time()
-        secs_of_diff = current_time - data_seconds
+        img_time = datetime.strptime(imagedata, u"%Y-%m-%dT%H:%M:%SZ") #not relative to localtime
+        now = datetime.utcnow() #timezones are UTC
+        delta = now - img_time
+        secs_of_diff = delta.seconds
         if waitTime > secs_of_diff:
             wikipedia.output(u'Skipping %s, uploaded %s seconds ago..' % (self.imageName, int(secs_of_diff)))
             return True # Still wait





More information about the Pywikipedia-l mailing list