use calendar.gmtime instead of time.mktime to avoid UTC/localtime issues with Flot stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Fri, 05 Feb 2010 17:57:51 +0100
branchstable
changeset 4501 71ba2d0f34f2
parent 4457 297a63704761
child 4502 1422589c35a0
use calendar.gmtime instead of time.mktime to avoid UTC/localtime issues with Flot This is suggested by the Flot documentation on http://people.iola.dk/olau/flot/API.txt
utils.py
--- a/utils.py	Thu Feb 04 18:29:43 2010 +0100
+++ b/utils.py	Fri Feb 05 17:57:51 2010 +0100
@@ -15,9 +15,9 @@
 import datetime as pydatetime
 from md5 import md5
 from datetime import datetime, timedelta, date
-from time import time, mktime
+from time import time
 from random import randint, seed
-from calendar import monthrange
+from calendar import monthrange, timegm
 
 # initialize random seed from current time
 seed()
@@ -44,7 +44,7 @@
     return datetime(somedate.year, somedate.month, somedate.day)
 
 def datetime2ticks(date):
-    return mktime(date.timetuple()) * 1000
+    return timegm(date.timetuple()) * 1000
 
 ONEDAY = timedelta(days=1)
 ONEWEEK = timedelta(days=7)