- Notifications
You must be signed in to change notification settings - Fork5.7k
Closed
Description
Steps to reproduce
job_queue.run_monthly(day=30, day_is_strict=False)
Expected behaviour
Runs on 30th day of each month excluding Feb + on Feb 28th/29th
Actual behaviour
Runs on 30thand 31st day of each month excluding Feb + on Feb 28th/29th
This happens because I didn't pay enough attention when writing this:
python-telegram-bot/telegram/ext/jobqueue.py
Lines 364 to 384 in0c50850
else: | |
trigger=OrTrigger( | |
[ | |
CronTrigger( | |
day=day, | |
hour=when.hour, | |
minute=when.minute, | |
second=when.second, | |
timezone=when.tzinfo, | |
**job_kwargs, | |
), | |
CronTrigger( | |
day='last', | |
hour=when.hour, | |
minute=when.minute, | |
second=when.second, | |
timezone=when.tzinfoorself.scheduler.timezone, | |
**job_kwargs, | |
), | |
] | |
) |
However, the use case ofday_is_strict
is mainly "run on the last day of the month". I therefore suggest to just drop the parameter and instead allow to passday='last'
orday=-1
(I like this one better) to indicate that you want to run the job on the last day of the month.
The use case described above can still be achieved withrun_custom
.