-
-
Notifications
You must be signed in to change notification settings - Fork 554
Fix: Corrects one-day discrepancy in estimated Islamic holidays for Iran #2885
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
base: dev
Are you sure you want to change the base?
Conversation
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
Signed-off-by: jntdst <jntdst@gmail.com>
fix(holidays): Correct one-day offset for estimated Iranian holidays Signed-off-by: jntdst <jntdst@gmail.com>
Summary by CodeRabbit
WalkthroughConstructor of Iran class now accepts variadic args/kwargs and removes islamic_show_estimated handling. Imports updated. A private override adjusts estimated Islamic holiday dates by +1 day before delegating to the parent method. Documentation updated accordingly. Public holiday population flow otherwise unchanged. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (18)📓 Common learnings
📚 Learning: 2025-06-13T12:18:03.539Z
Applied to files:
📚 Learning: 2025-07-10T15:55:34.523Z
Applied to files:
📚 Learning: 2025-08-22T19:06:04.303Z
Applied to files:
📚 Learning: 2025-08-25T04:28:02.061Z
Applied to files:
📚 Learning: 2025-06-04T10:09:28.732Z
Applied to files:
📚 Learning: 2025-04-13T19:10:31.502Z
Applied to files:
📚 Learning: 2025-03-30T08:08:30.415Z
Applied to files:
📚 Learning: 2025-03-30T18:22:11.939Z
Applied to files:
📚 Learning: 2025-08-21T04:56:03.780Z
Applied to files:
📚 Learning: 2025-06-19T02:34:14.456Z
Applied to files:
📚 Learning: 2025-08-21T05:56:33.276Z
Applied to files:
📚 Learning: 2025-06-19T02:34:18.382Z
Applied to files:
📚 Learning: 2025-08-21T04:56:03.780Z
Applied to files:
📚 Learning: 2025-05-06T13:01:22.693Z
Applied to files:
📚 Learning: 2025-08-26T21:24:41.827Z
Applied to files:
📚 Learning: 2025-06-16T14:08:09.492Z
Applied to files:
📚 Learning: 2025-06-29T10:36:06.138Z
Applied to files:
🧬 Code graph analysis (1)holidays/countries/iran.py (2)
🔇 Additional comments (3)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
holidays/countries/iran.py
Outdated
def __init__(self, *args, islamic_show_estimated: bool = True, **kwargs): | ||
def __init__(self, *args, **kwargs): | ||
""" | ||
Args: | ||
islamic_show_estimated: | ||
Whether to add "estimated" label to Islamic holidays name | ||
if holiday date is estimated. | ||
Initializes the Iran holidays class. | ||
The `islamic_show_estimated` parameter is removed and forced to False | ||
to handle date corrections internally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to remove this parameter, False
as default value is enough.
for dt, is_estimated in dates: | ||
if is_estimated: | ||
# Add one day to estimated dates to correct them. | ||
corrected_dates.append((dt + timedelta(days=1), is_estimated)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have _timedelta
function in holidays.calendars.gregorian
for that.
Proposed change
This PR addresses and fixes a one-day discrepancy for estimated Islamic (lunar) holidays in Iran.
Currently, future lunar holidays calculated by the library for Iran are consistently off by one day compared to the official Iranian calendar. For example, an event officially on a Tuesday is often incorrectly listed as Monday (estimated). This causes reliability issues for users planning based on future dates.
This change implements a structural fix directly within the Iran class in holidays/countries/iran.py:
The _add_islamic_calendar_holiday method is overridden: This method now intercepts Islamic holidays before they are added.
Automatic Date Correction: If a holiday is flagged as is_estimated, the method automatically adds timedelta(days=1) to its date, aligning it with the official calendar.
Removal of "(estimated)" Label: The islamic_show_estimated flag is now forced to False in the class constructor. Since the dates are corrected, displaying the "estimated" label is no longer necessary and would be confusing.
This approach provides a permanent and transparent solution, ensuring that all future holiday calculations for Iran are accurate without requiring any post-processing by the end-user.
Type of change
[ ] New country/market holidays support (thank you!)
[x] Supported country/market holidays update (calendar discrepancy fix, localization)
[ ] Existing code/documentation/test/process quality improvement (best practice, cleanup, refactoring, optimization)
[ ] Dependency update (version deprecation/pin/upgrade)
[ ] Bugfix (non-breaking change which fixes an issue)
[ ] Breaking change (a code change causing existing functionality to break)
[ ] New feature (new holidays functionality in general)
Checklist
[* ] I've read and followed the contributing guidelines.
[* ] I've run make check locally; all checks and tests passed.