Add _IslamicMabimsLunar calendar class for MABIMS crescent visibility criteria
Proposed change
Uses skyfield to calculate moon positions at Singapore sunset Applies MABIMS 2021 criteria (altitude >= 3°, geocentric elongation >= 6.4°) Generates pre-computed date tables covering 1925-2052 for 7 Islamic holidays (Eid al-Fitr, Eid al-Adha, Hijri New Year, Isra and Miraj, Mawlid, Nuzul al-Quran, Ramadan Beginning)
Dates are based on Singapore's MUIS (Majlis Ugama Islam Singapura) astronomical calculations (Hisab) as the primary reference source, covering Eid al-Fitr and Eid al-Adha from 2001 to 2026.
Related to #2334
Type of change
- [ ] New country/market holidays support (thank you!)
- [ ] 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)
- [x] New feature (new
holidaysfunctionality in general)
Checklist
- [x] I've read and followed the contributing guidelines.
- [x] I've run
make checklocally; all checks and tests passed.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
Walkthrough
Adds _IslamicMabimsLunar — a MABIMS-based Islamic calendar subclass extending _IslamicLunar, introduces confirmed-year constants and Eid/ramadan lookup/shift logic (2001–2026), exports it from the package, and adds tests validating expected and fallback behaviors.
Changes
MABIMS Islamic Calendar
| Layer / File(s) | Summary |
|---|---|
Confirmed-year constants in _IslamicLunar holidays/calendars/islamic.py |
Adds EID_AL_FITR_DATES_CONFIRMED_YEARS and EID_AL_ADHA_DATES_CONFIRMED_YEARS = (2001, 2026) to _IslamicLunar. |
MABIMS calendar class and visibility logic holidays/calendars/islamic.py |
Adds _IslamicMabimsLunar subclass with LATITUDE/LONGITUDE, solar/lunar position helpers, _check_mabims_criteria, and overrides for eid_al_fitr_dates, eid_al_adha_dates, and ramadan_beginning_dates that apply a one-day shift when MABIMS criteria are not met. |
Calendar package export holidays/calendars/__init__.py |
Exports _IslamicMabimsLunar from the holidays.calendars package namespace. |
Calendar test suite tests/calendars/test_islamic.py |
Adds TestIslamicMabimsLunar with tests for Eid al‑Fitr and Eid al‑Adha expected dates, a 2006 dual-date case, and fallback tests for years outside the confirmed range. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related issues
- vacanza/holidays#2334: Directly implements the MABIMS calendar variant and Eid/ramadan logic described in this issue.
Possibly related PRs
- vacanza/holidays#2753: Extends
_IslamicLunarwith helper methods that relate to the new MABIMS subclass.
Suggested labels
test, snapshot
Suggested reviewers
- arkid15r
- KJhellico
- PPsyrius
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title directly and specifically describes the main change: adding a new _IslamicMabimsLunar calendar class implementing MABIMS crescent visibility criteria. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Description check | ✅ Passed | The PR description clearly relates to the changeset, detailing Islamic calendar calculations using MABIMS criteria and skyfield library integration. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with 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.
Comment @coderabbitai help to get the list of available commands.
@akshiDhi, #2334 is to implement the calculation of the start dates of Islamic months according to MABIMS criteria, not just to take the dates of two holidays within a narrow range of years.
Quality Gate passed
Issues
4 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
i updated the implementation following the feedback.
You're iterating quickly on this pull request. To help protect your rate limits, cubic has paused automatic reviews on new pushes for now—when you're ready for another review, comment @cubic-dev-ai review.
General advice on the algorithm:
- use new moon moments instead of HijriDate-calculated dates for reference points
- implement the methods in a separate class, as in other generators (this will allow to avoid passing unnecessary parameters)
I have updated the PR based on your feedback:
- Refactored
mabims_generator.pyinto a separate class (_MabimsLunar) to encapsulate the calculations. - Replaced the
hijridateapproximation with direct astronomical new moon calculations usingMEAN_SYNODIC_MONTHand Skyfield.
- direct astronomical new moon calculations using
MEAN_SYNODIC_MONTHand Skyfield
If you're already using Skyfield, you should take advantage of its features, including calculating arrays of values all at once, rather than one by one. I mean something like
times, events = almanac.find_discrete(t0, t1, almanac.moon_phases(eph))
new_moons = [
moment for moment, phase in zip(times, events) if phase == 0
]
for the entire timeframe.
Quality Gate passed
Issues
4 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
thank you ! I updated the script to take advantage of Skyfield's vector arrays. (i chunked the find_discrete() calls year-by-year in a loop to avoid a Skyfield memory error)