Closed Wissperwind closed 3 years ago
I did this:
import datetime
day = datetime.datetime.today().weekday()
if day < 5:
#schedule
else:
print("Weekend")
So you do the scheduling part yourself. Ok. But that is not the joke when using the schedule lib. I also need to cancel jobs. So I would need to schedule 5 jobs and make a special treetment for the cancellation because it needs to know that it has to cancle 5 jobs..
While we can work on something like every().workday.do(), where the new workdays array in the library can be as:
workdays = [ "monday", "tuesday", "wednesday", "thursday", "friday" ]
I do not think schedule as a library is meant for that. Here is the doc link for reference: when not to use a schdule
Moreover, workdays as a parameter are defined different from different organisations.
Hi! You could run a job daily and skip the execution on saturdays and sundays. This would look like this:
import schedule
import datetime
def job():
# Monday is 0 and Friday is 4
if datetime.datetime.today().weekday() > 4:
return
# do whatever needs to do
pass
schedule.every().day.at("10:00").do(job)
If you have any more questions, feel free to open a new ticket :+1:
Yes, I can use this workaround. I think it would improve the library to add it, but if you don't agree. It's your library. But thanks for the open discussion.
Hi, I need do schedule a job every monday to friday at 10:00. Is there alread an option I missed? Can we get one?
Thanks!