aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmproxy/proxy.py8
-rw-r--r--libmproxy/utils.py12
-rw-r--r--test/test_utils.py2
3 files changed, 15 insertions, 7 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index 2a2904e5..a4dc3e69 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -5,7 +5,7 @@
Development started from Neil Schemenauer's munchy.py
"""
-import sys, os, time, string, socket, urlparse, re, select, copy, base64
+import sys, os, string, socket, urlparse, re, select, copy, base64
import shutil, tempfile
import optparse, SocketServer, ssl
import utils, controller
@@ -132,7 +132,7 @@ class Request(controller.Msg):
self.client_conn = client_conn
self.host, self.port, self.scheme = host, port, scheme
self.method, self.path, self.headers, self.content = method, path, headers, content
- self.timestamp = timestamp or time.time()
+ self.timestamp = timestamp or utils.timestamp()
self.close = False
controller.Msg.__init__(self)
@@ -262,7 +262,7 @@ class Response(controller.Msg):
self.request = request
self.code, self.msg = code, msg
self.headers, self.content = headers, content
- self.timestamp = timestamp or time.time()
+ self.timestamp = timestamp or utils.timestamp()
self.cached = False
controller.Msg.__init__(self)
self.replay = False
@@ -376,7 +376,7 @@ class ClientConnect(controller.Msg):
class Error(controller.Msg):
def __init__(self, request, msg, timestamp=None):
self.request, self.msg = request, msg
- self.timestamp = timestamp or time.time()
+ self.timestamp = timestamp or utils.timestamp()
controller.Msg.__init__(self)
def load_state(self, state):
diff --git a/libmproxy/utils.py b/libmproxy/utils.py
index d4b72cb6..5f0b833d 100644
--- a/libmproxy/utils.py
+++ b/libmproxy/utils.py
@@ -12,10 +12,18 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import re, os, subprocess, datetime, textwrap, errno, sys
+import re, os, subprocess, datetime, textwrap, errno, sys, time, pytz
+
+
+def timestamp():
+ d = datetime.datetime.utcnow()
+ return list(d.timetuple())
+
def format_timestamp(s):
- d = datetime.datetime.fromtimestamp(s)
+ s = time.struct_time(s)
+ d = datetime.datetime.fromtimestamp(time.mktime(s))
+ d = d - datetime.timedelta(seconds=time.altzone)
return d.strftime("%Y-%m-%d %H:%M:%S")
diff --git a/test/test_utils.py b/test/test_utils.py
index be6db4d3..c7d4e03f 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -5,7 +5,7 @@ from libmproxy import utils
class uformat_timestamp(libpry.AutoTree):
def test_simple(self):
- assert utils.format_timestamp(time.time())
+ assert utils.format_timestamp(utils.timestamp())
class uisBin(libpry.AutoTree):