Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions telegram/ext/jobqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def tick(self):
if job.enabled:
try:
current_week_day = datetime.datetime.now(job.tzinfo).date().weekday()
if any(day == current_week_day for day in job.days):
if current_week_day in job.days:
self.logger.debug('Running job %s', job.name)
job.run(self._dispatcher)

Expand Down Expand Up @@ -387,7 +387,7 @@ def __init__(self,
days=Days.EVERY_DAY,
name=None,
job_queue=None,
tzinfo=_UTC):
tzinfo=None):

self.callback = callback
self.context = context
Expand All @@ -400,7 +400,7 @@ def __init__(self,

self._days = None
self.days = days
self.tzinfo = tzinfo
self.tzinfo = tzinfo or _UTC

self._job_queue = weakref.proxy(job_queue) if job_queue is not None else None

Expand Down
13 changes: 12 additions & 1 deletion tests/test_jobqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from telegram.ext import JobQueue, Updater, Job, CallbackContext
from telegram.utils.deprecate import TelegramDeprecationWarning
from telegram.utils.helpers import _UtcOffsetTimezone
from telegram.utils.helpers import _UtcOffsetTimezone, _UTC


@pytest.fixture(scope='function')
Expand Down Expand Up @@ -325,3 +325,14 @@ def test_context_based_callback(self, job_queue):
sleep(0.03)

assert self.result == 0

def test_job_default_tzinfo(self, job_queue):
"""Test that default tzinfo is always set to UTC"""
job_1 = job_queue.run_once(self.job_run_once, 0.01)
job_2 = job_queue.run_repeating(self.job_run_once, 10)
job_3 = job_queue.run_daily(self.job_run_once, time=dtm.time(hour=15))

jobs = [job_1, job_2, job_3]

for job in jobs:
assert job.tzinfo == _UTC