Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior for day checking is incorrect #29

Closed
kenahoo opened this issue Jun 23, 2022 · 1 comment · Fixed by #34
Closed

Behavior for day checking is incorrect #29

kenahoo opened this issue Jun 23, 2022 · 1 comment · Fixed by #34

Comments

@kenahoo
Copy link

kenahoo commented Jun 23, 2022

The docs for crontab (https://man7.org/linux/man-pages/man5/crontab.5.html) say this:

Commands are executed by cron(8) when the 'minute', 'hour', and 'month of the year' fields match the current time, and at least one of the two 'day' fields ('day of month', or 'day of week') match the current time (see "Note" below).

and here's the Note:

Note: The day of a command's execution can be specified in the following two fields — 'day of month', and 'day of week'. If both fields are restricted (i.e., do not contain the "*" character), the command will be run when either field matches the current time. For example, "30 4 1,15 * 5" would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.

However, the pycron functionality is different - it requires that both the fields match:

>>> import pycron
>>> from datetime import datetime
>>> dt = datetime(2022, 6, 23)  # A Thursday
>>> pycron.is_now('* * 22 * thu', dt)
False
>>> pycron.is_now('* * 23 * thu', dt)
True
>>> pycron.is_now('* * 23 * fri', dt)
False
@adamsxs
Copy link

adamsxs commented Sep 19, 2024

kipe added a commit that referenced this issue Sep 27, 2024
- Added a special case handling when both 'day' fields are set to allow either one to match. This addresses issue #29.
- Updated the parsing logic for 'dom' and 'dow' arguments, using `_parse_arg` function with appropriate default values.
@kipe kipe linked a pull request Sep 27, 2024 that will close this issue
@kipe kipe closed this as completed in #34 Sep 27, 2024
kipe added a commit that referenced this issue Sep 27, 2024
- Added a special case handling when both 'day' fields are set to allow either one to match. This addresses issue #29.
- Updated the parsing logic for 'dom' and 'dow' arguments, using `_parse_arg` function with appropriate default values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants