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

Fix invalid date handling in cron occurrence calculation #14

Merged

Conversation

siddarth-patil
Copy link
Owner

This fixes the #11 issue.
This commit addresses an issue where the cron occurrence calculation could attempt to create invalid dates, such as February 29th in non-leap years. The changes include:

  • Combining two separate checks for day_of_month validity into a single condition for efficiency.
  • Implementing a helper method __is_valid_date to verify date validity.
  • Ensuring that when an invalid date is encountered, the calculation moves to the next month and continues the search.
  • Added test cases to cover this change.

This commit addresses an issue where the cron occurrence calculation could
attempt to create invalid dates, such as February 29th in non-leap years.
The changes include:

- Combining two separate checks for day_of_month validity into a single condition for efficiency.
- Implementing a helper method __is_valid_date to verify date validity.
- Ensuring that when an invalid date is encountered, the calculation moves to the next month and continues the search.
- Added test cases to cover this change.
@siddarth-patil siddarth-patil linked an issue Jan 20, 2025 that may be closed by this pull request
@siddarth-patil siddarth-patil merged commit dd36d9c into main Jan 20, 2025
10 checks passed
@siddarth-patil siddarth-patil deleted the 11-bug-valueerror-day-is-out-of-range-for-month branch January 20, 2025 16:28
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 this pull request may close these issues.

[BUG] ValueError: day is out of range for month
1 participant