From 58175d8ba934854649bdf49f42db3cb763f98b30 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Tue, 26 Apr 2016 17:13:58 +0100 Subject: [PATCH] Fix handling of edproxy UTC timestamps Courtesy of @andrewgoz. Fixes #107. --- edproxy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/edproxy.py b/edproxy.py index 607bc59f..4eb55be9 100644 --- a/edproxy.py +++ b/edproxy.py @@ -9,6 +9,7 @@ import sys import threading from time import time, strptime, mktime from datetime import datetime +from calendar import timegm if __debug__: from traceback import print_exc @@ -113,7 +114,7 @@ class _EDProxy: s.settimeout(0) s.sendall(json.dumps({ 'Type' : 'Init', - 'DateUtc' : datetime.now().isoformat(), + 'DateUtc' : datetime.utcnow().isoformat(), 'StartTime' : 'now', 'Register' : [ 'System' ], })) @@ -132,7 +133,7 @@ class _EDProxy: msg = json.loads(s.recv(self.MESSAGE_MAX)) if msg['Type'] == self.MESSAGE_SYSTEM: if 'DateUtc' in msg: - timestamp = mktime(datetime.strptime(msg['DateUtc'], '%Y-%m-%d %H:%M:%S').utctimetuple()) + timestamp = timegm(datetime.strptime(msg['DateUtc'], '%Y-%m-%d %H:%M:%S').utctimetuple()) else: timestamp = mktime(strptime(msg['Date'], '%Y-%m-%d %H:%M:%S')) # from local time self.last_event = (timestamp, msg['System'])