-
-
Notifications
You must be signed in to change notification settings - Fork 705
Add _IslamicMabimsLunar calendar class for MABIMS crescent visibility criteria #3603
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?
Changes from 24 commits
651c918
8550906
dbe49a3
cacf5a0
8d64af1
29c6578
e8af34e
8ab8b24
3723791
cdc2bdc
01ffee1
161763a
5209112
658ee68
962c762
38630e0
bf0f4f3
2bf099b
f067db9
b00c438
ab3aa34
2898021
6855009
b61f1b7
2aa88da
777cbea
af2db00
d6733b0
abc656a
e5e9cfb
85349e6
250b191
1a476ff
60e9d52
65b762c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # holidays | ||
| # -------- | ||
| # A fast, efficient Python library for generating country, province and state | ||
| # specific sets of holidays on the fly. It aims to make determining whether a | ||
| # specific date is a holiday as fast and flexible as possible. | ||
| # | ||
| # Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) | ||
| # dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
| # ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
| # Website: https://github.com/vacanza/holidays | ||
| # License: MIT (see LICENSE file) | ||
|
|
||
| import unittest | ||
| from datetime import date | ||
|
|
||
| from holidays.calendars.gregorian import FEB, MAR, APR, MAY, JUN, JUL, OCT, NOV, DEC | ||
| from holidays.calendars.islamic import _IslamicMabimsLunar | ||
|
|
||
|
|
||
| class TestIslamicMabimsLunar(unittest.TestCase): | ||
| def setUp(self) -> None: | ||
| super().setUp() | ||
| self.calendar = _IslamicMabimsLunar() | ||
|
|
||
| def test_eid_al_fitr_dates(self): | ||
| eid_al_fitr_dates = { | ||
| 2001: date(2001, DEC, 16), | ||
| 2002: date(2002, DEC, 6), | ||
| 2003: date(2003, NOV, 25), | ||
| 2006: date(2006, OCT, 24), | ||
| 2019: date(2019, JUN, 5), | ||
| 2022: date(2022, MAY, 3), | ||
| 2023: date(2023, APR, 22), | ||
| 2024: date(2024, APR, 10), | ||
| 2025: date(2025, MAR, 31), | ||
| 2026: date(2026, MAR, 21), | ||
| } | ||
| for year, expected_date in eid_al_fitr_dates.items(): | ||
| dates = {dt: is_estimated for dt, is_estimated in self.calendar.eid_al_fitr_dates(year)} | ||
|
Check warning on line 39 in tests/calendars/test_islamic.py
|
||
| self.assertIn(expected_date, dates) | ||
| self.assertFalse(dates[expected_date], f"Eid al-Fitr {year} should be confirmed, not estimated") | ||
|
|
||
| def test_eid_al_adha_dates(self): | ||
| eid_al_adha_dates = { | ||
| 2001: date(2001, MAR, 6), | ||
| 2002: date(2002, FEB, 23), | ||
| 2006: date(2006, DEC, 31), | ||
| 2010: date(2010, NOV, 17), | ||
| 2014: date(2014, OCT, 5), | ||
| 2022: date(2022, JUL, 10), | ||
| 2023: date(2023, JUN, 29), | ||
| 2024: date(2024, JUN, 17), | ||
| 2025: date(2025, JUN, 7), | ||
| 2026: date(2026, MAY, 27), | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| for year, expected_date in eid_al_adha_dates.items(): | ||
| dates = {dt: is_estimated for dt, is_estimated in self.calendar.eid_al_adha_dates(year)} | ||
|
Check warning on line 57 in tests/calendars/test_islamic.py
|
||
| self.assertIn(expected_date, dates) | ||
| self.assertFalse(dates[expected_date], f"Eid al-Adha {year} should be confirmed, not estimated") | ||
|
|
||
| def test_eid_al_adha_2006_dual_date(self): | ||
| """2006 has two Eid al-Adha dates - Jan 10 and Dec 31.""" | ||
| dates = {dt for dt, _ in self.calendar.eid_al_adha_dates(2006)} | ||
| self.assertIn(date(2006, 1, 10), dates) | ||
| self.assertIn(date(2006, 12, 31), dates) | ||
|
|
||
| def test_fallback_to_base_outside_range(self): | ||
| """Years outside 2001-2026 should fall back to base _IslamicLunar dates.""" | ||
| dates_1990 = list(self.calendar.eid_al_fitr_dates(1990)) | ||
| dates_2030 = list(self.calendar.eid_al_fitr_dates(2030)) | ||
| self.assertTrue(len(dates_1990) > 0) | ||
|
Check warning on line 71 in tests/calendars/test_islamic.py
|
||
| self.assertTrue(len(dates_2030) > 0) | ||
|
Check warning on line 72 in tests/calendars/test_islamic.py
|
||
| # Outside confirmed range should be estimated | ||
| for _, is_estimated in dates_1990: | ||
| self.assertTrue(is_estimated) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
Uh oh!
There was an error while loading. Please reload this page.