From 9981a90b46160ac71505cb790c4bda4ee037ebb4 Mon Sep 17 00:00:00 2001 From: David Lord Date: Mon, 11 Apr 2016 19:34:14 -0700 Subject: [PATCH] use full timestamps, no cutoff at 2011, fixes #46 --- itsdangerous.py | 8 ++------ tests.py | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/itsdangerous.py b/itsdangerous.py index 7b7988d..577d01d 100644 --- a/itsdangerous.py +++ b/itsdangerous.py @@ -52,10 +52,6 @@ def dumps(self, obj): compact_json = _CompactJSON() -# 2011/01/01 in UTC -EPOCH = 1293840000 - - def want_bytes(s, encoding='utf-8', errors='strict'): if isinstance(s, text_type): s = s.encode(encoding, errors) @@ -393,13 +389,13 @@ def get_timestamp(self): """Returns the current timestamp. This implementation returns the seconds since 1/1/2011. The function must return an integer. """ - return int(time.time() - EPOCH) + return int(time.time()) def timestamp_to_datetime(self, ts): """Used to convert the timestamp from `get_timestamp` into a datetime object. """ - return datetime.utcfromtimestamp(ts + EPOCH) + return datetime.utcfromtimestamp(ts) def sign(self, value): """Signs the given string and also attaches a time information.""" diff --git a/tests.py b/tests.py index c1609b0..067cc3e 100755 --- a/tests.py +++ b/tests.py @@ -126,7 +126,7 @@ class TimedSerializerTestCase(SerializerTestCase): def setUp(self): self._time = time.time - time.time = lambda: idmod.EPOCH + time.time = lambda: 0 def tearDown(self): time.time = self._time @@ -140,7 +140,7 @@ def test_decode_with_timeout(self): self.assertNotEqual(ts, idmod.Serializer(secret_key).dumps(value)) self.assertEqual(s.loads(ts), value) - time.time = lambda: idmod.EPOCH + 10 + time.time = lambda: 10 self.assertEqual(s.loads(ts, max_age=11), value) self.assertEqual(s.loads(ts, max_age=10), value) self.assertRaises(