From e54a3188ce6efd19622529e6f0c33d3ca0ea2c76 Mon Sep 17 00:00:00 2001 From: Jasmin Bom Date: Sat, 9 Feb 2019 18:44:04 +0100 Subject: [PATCH] Revert "Fix bug: unable to save jobs with timezone aware dates (#1308)" This reverts commit 23fe991b See https://github.com/python-telegram-bot/python-telegram-bot/pull/1308 for more details. NOTE: Keeping Ambro17 in AUTHORS.rst as I'm pretty sure they've contributed more since then :) --- telegram/ext/jobqueue.py | 2 +- tests/test_jobqueue.py | 18 ------------------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/telegram/ext/jobqueue.py b/telegram/ext/jobqueue.py index ec9dc12b8..e6eb36012 100644 --- a/telegram/ext/jobqueue.py +++ b/telegram/ext/jobqueue.py @@ -62,7 +62,7 @@ class JobQueue(object): raise ValueError('next_t is None') if isinstance(next_t, datetime.datetime): - next_t = (next_t - datetime.datetime.now(next_t.tzinfo)).total_seconds() + next_t = (next_t - datetime.datetime.now()).total_seconds() elif isinstance(next_t, datetime.time): next_datetime = datetime.datetime.combine(datetime.date.today(), next_t) diff --git a/tests/test_jobqueue.py b/tests/test_jobqueue.py index 691fb0a21..083a3d194 100644 --- a/tests/test_jobqueue.py +++ b/tests/test_jobqueue.py @@ -184,24 +184,6 @@ class TestJobQueue(object): sleep(0.06) assert pytest.approx(self.job_time) == expected_time - def test_datetime_with_timezone_job_run_once(self, job_queue): - # Test that run_once jobs work with timezone aware datetimes. - offset = datetime.timedelta(hours=-3) - when = datetime.datetime.now(datetime.timezone(offset)) - - job_queue.run_once(self.job_run_once, when) - sleep(0.01) - assert self.result == 1 - - def test_datetime_with_timezone_job_run_repeating(self, job_queue): - # Test that run_repeating jobs work with timezone aware datetimes. - offset = datetime.timedelta(hours=5) - now_with_offset = datetime.datetime.now(datetime.timezone(offset)) - - job_queue.run_repeating(self.job_run_once, interval=0.01, first=now_with_offset) - sleep(0.015) - assert self.result == 2 - def test_time_unit_dt_time_today(self, job_queue): # Testing running at a specific time today delta = 0.05