Pass in day name
- Dominant language
- Python
- Stars
- 12.3k
- Forks
- 999
- PR merge metrics
- No merged PRs in 30d
Description
Firstly, thanks for writing schedule! It is fantastic and I have used it a tonne.
I am getting user input to ascertain which days the program should execute. Though I never normally trust a user, for the sake of simplicity here, we shall assume that the user is infallible.
```python
day_name = input("Day: ")
```
The docs show that one can specify days to run a function on as follows.
```python
schedule.every().monday.do(job)
schedule.every().wednesday.at("13:15").do(job)
```
Unfortunately, I cannot see a way to pass a day name or value into schedule. As such, I am currently running a "check day" job every day.
```python
def check_day():
day_today = datetime.today().strftime("%A")
if day_today.lower() != str(input_day).lower():
return
schedule.every().day.at(go_time).do(job)
def main():
schedule.every().day.at("00:01").do(check_day)
while True:
n = schedule.idle_seconds()
if n is None:
# no more jobs
break
elif n > 0:
# sleep exactly the right amount of time
sleep(n)
schedule.run_pending()
```
This seems a bit inefficient, particularly when there is nothing to do for several days.
**TL;DR**
It would be great to be able to pass in a day name or number as a variable.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the documented schedule.every().monday and schedule.every().wednesday.at(...) entry points, then trace how day-specific scheduling is represented. Done means a caller can provide a day name or number as a variable and schedule the job directly, without running a daily check job.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100