-
-
Notifications
You must be signed in to change notification settings - Fork 689
Update Pakistan holidays: add OPTIONAL category support
#3331
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 all commits
21585f8
36efd5f
a212bb6
e5cd06d
2300b6e
58d34d2
df52be7
eda2b77
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 |
|---|---|---|
|
|
@@ -14,18 +14,33 @@ | |
|
|
||
| from holidays.calendars import _CustomIslamicHolidays | ||
| from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC | ||
| from holidays.groups import InternationalHolidays, IslamicHolidays | ||
| from holidays.constants import OPTIONAL, PUBLIC, CHRISTIAN | ||
| from holidays.groups import ( | ||
| InternationalHolidays, | ||
| IslamicHolidays, | ||
| ChristianHolidays, | ||
| HinduCalendarHolidays, | ||
| BuddhistCalendarHolidays, | ||
| ) | ||
| from holidays.holiday_base import HolidayBase | ||
|
|
||
|
|
||
| class Pakistan(HolidayBase, InternationalHolidays, IslamicHolidays): | ||
| class Pakistan( | ||
| HolidayBase, | ||
| InternationalHolidays, | ||
| IslamicHolidays, | ||
| ChristianHolidays, | ||
| HinduCalendarHolidays, | ||
| BuddhistCalendarHolidays, | ||
| ): | ||
| """Pakistan holidays. | ||
|
|
||
| References: | ||
| * <https://en.wikipedia.org/wiki/Public_holidays_in_Pakistan> | ||
| * <https://ur.wikipedia.org/wiki/تعطیلات_پاکستان> | ||
| * [Public and optional holidays](https://web.archive.org/web/20250118105814/https://cabinet.gov.pk/Detail/OTE2ODBiYmItZmI0MS00NDAwLWE5NGUtYmE1MGVjYzllMzAz) | ||
| * [No.10-01/2024-Min-II](https://web.archive.org/web/20241103080918/https://cabinet.gov.pk/SiteImage/Misc/files/Holidays/28-5-24.pdf) | ||
| * [Public and optional holidays, 2026](https://cabinet.gov.pk/SiteImage/Misc/files/Holidays/2026/Public-Holidays-2026.pdf) | ||
| """ | ||
|
|
||
| country = "PK" | ||
|
|
@@ -35,6 +50,7 @@ class Pakistan(HolidayBase, InternationalHolidays, IslamicHolidays): | |
| # Achieved Independence on August 14th, 1947. | ||
| start_year = 1948 | ||
| supported_languages = ("en_PK", "en_US", "ur_PK") | ||
| supported_categories = (OPTIONAL, PUBLIC, CHRISTIAN) | ||
|
|
||
| def __init__(self, *args, islamic_show_estimated: bool = True, **kwargs): | ||
| """ | ||
|
|
@@ -47,6 +63,9 @@ def __init__(self, *args, islamic_show_estimated: bool = True, **kwargs): | |
| IslamicHolidays.__init__( | ||
| self, cls=PakistanIslamicHolidays, show_estimated=islamic_show_estimated | ||
| ) | ||
| ChristianHolidays.__init__(self) | ||
| HinduCalendarHolidays.__init__(self) | ||
| BuddhistCalendarHolidays.__init__(self) | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| def _populate_public_holidays(self): | ||
|
|
@@ -96,6 +115,66 @@ def _populate_public_holidays(self): | |
| self._add_ashura_eve(name) | ||
| self._add_ashura_day(name) | ||
|
|
||
| def _populate_optional_holidays(self): | ||
|
|
||
| # New Year's Day | ||
| self._add_new_years_day(tr("New Year's Day")) | ||
|
|
||
| # Islamic optional holidays (estimated) | ||
| if self._year == 2026: | ||
| self._add_holiday(tr("Shab-e-Meraj (estimated)"), JAN, 17) | ||
| self._add_holiday(tr("Shab-e-Barat (estimated)"), FEB, 4) | ||
| self._add_holiday(tr("Chehlum (estimated)"), AUG, 4) | ||
| self._add_holiday(tr("Giyarvee Shareef (estimated)"), SEP, 23) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| # Hindu & Sikh holidays | ||
| self._add_holiday(tr("Basant Panchami"), JAN, 23) | ||
| self._add_holiday(tr("Shiv Ratri"), FEB, 16) | ||
| self._add_holiday(tr("Dulhandi"), MAR, 3) | ||
| self._add_holiday(tr("Holi"), MAR, 4) | ||
|
|
||
| # Christian holidays | ||
|
|
||
| # Good Friday. | ||
| self._add_good_friday(tr("Good Friday")) | ||
|
|
||
| # Easter Sunday. | ||
| self._add_easter_sunday(tr("Easter Sunday")) | ||
|
|
||
| # Easter Monday. | ||
| self._add_easter_monday(tr("Easter Monday")) | ||
|
SaadBazaz marked this conversation as resolved.
|
||
|
|
||
| # Sikh holidays | ||
| self._add_holiday(tr("Baisakhi"), APR, 14) | ||
|
|
||
| # Bahai holidays | ||
| self._add_holiday(tr("Eid-e-Rizwan (Bahai)"), APR, 21) | ||
|
|
||
| # Buddhist holidays | ||
| self._add_holiday(tr("Buddha Purnima"), MAY, 24) | ||
|
Comment on lines
+153
to
+154
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure this one is a movable holiday, the same goes for Hindu ones |
||
|
|
||
| # Parsi holidays | ||
| self._add_holiday(tr("Nauroze (Parsi New Year)"), AUG, 15) | ||
| self._add_holiday(tr("Birthday of Lord Zoroaster (Khordad Sal)"), AUG, 20) | ||
|
|
||
| # Hindu holidays | ||
| self._add_holiday(tr("Krishna Janmashtami"), SEP, 4) | ||
| self._add_holiday(tr("Durga Puja"), OCT, 19) | ||
| self._add_holiday(tr("Dussehra"), OCT, 20) | ||
| self._add_holiday(tr("Dussehra Holiday"), OCT, 26) | ||
| self._add_diwali(tr("Diwali")) | ||
|
|
||
| # Sikh holidays | ||
| self._add_holiday(tr("Birthday of Guru Nanak Dev Ji"), NOV, 24) | ||
| self._add_holiday(tr("Birthday of Guru Valmiki Ji"), NOV, 30) | ||
|
|
||
| def _populate_christian_holidays(self): | ||
| # Christmas Day. | ||
| self._add_christmas_day(tr("Christmas Day")) | ||
|
|
||
| # Day after Christmas | ||
| self._add_holiday_dec_26(tr("Day after Christmas")) | ||
|
|
||
|
|
||
| class PK(Pakistan): | ||
| pass | ||
|
|
@@ -109,15 +188,16 @@ class PakistanIslamicHolidays(_CustomIslamicHolidays): | |
| # https://web.archive.org/web/20250724060822/https://www.timeanddate.com/holidays/pakistan/ashura | ||
| ASHURA_DATES_CONFIRMED_YEARS = (2005, 2025) | ||
| ASHURA_DATES = { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the source of dates information? (I see some discrepancies with Timeanddate, which isn't 100% reliable either). |
||
| 2005: (FEB, 18), | ||
| 2006: (FEB, 8), | ||
| 2007: (JAN, 28), | ||
| 2008: (JAN, 18), | ||
| 2009: ((JAN, 6), (DEC, 26)), | ||
| 2012: (NOV, 23), | ||
| 2018: (SEP, 21), | ||
| 2022: (AUG, 9), | ||
| 2005: (FEB, 19), | ||
| 2006: (FEB, 9), | ||
| 2007: (JAN, 29), | ||
| 2008: (JAN, 19), | ||
| 2009: ((JAN, 7), (DEC, 27)), | ||
| 2012: (NOV, 24), | ||
| 2018: (SEP, 20), | ||
| 2022: (AUG, 8), | ||
| 2025: (JUL, 6), | ||
| 2026: (JUN, 25), | ||
| } | ||
|
|
||
| # https://web.archive.org/web/20250724060629/https://www.timeanddate.com/holidays/pakistan/eid-ul-azha | ||
|
|
@@ -138,6 +218,7 @@ class PakistanIslamicHolidays(_CustomIslamicHolidays): | |
| 2023: (JUN, 29), | ||
| 2024: (JUN, 17), | ||
| 2025: (JUN, 7), | ||
| 2026: (MAY, 27), | ||
| } | ||
|
|
||
| # https://web.archive.org/web/20250724060834/https://www.timeanddate.com/holidays/pakistan/eid-ul-fitr-1 | ||
|
|
@@ -155,10 +236,10 @@ class PakistanIslamicHolidays(_CustomIslamicHolidays): | |
| 2022: (MAY, 3), | ||
| 2023: (APR, 22), | ||
| 2025: (MAR, 31), | ||
| 2026: (MAR, 21), | ||
| } | ||
|
|
||
| # https://web.archive.org/web/20250724061027/https://www.timeanddate.com/holidays/pakistan/eid-milad-un-nabi | ||
|
|
||
| MAWLID_DATES_CONFIRMED_YEARS = (2005, 2024) | ||
| MAWLID_DATES = { | ||
| 2005: (APR, 22), | ||
|
|
@@ -178,4 +259,5 @@ class PakistanIslamicHolidays(_CustomIslamicHolidays): | |
| 2022: (OCT, 9), | ||
| 2023: (SEP, 29), | ||
| 2024: (SEP, 17), | ||
| 2026: (AUG, 25), | ||
| } | ||
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.
It doesn't make sense to add holidays for a single year only in this way.
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.
@KJhellico - do you recommend I follow the format here:
https://github.com/SaadBazaz/holidays/blob/2300b6e9b5f7f954b2ed35b9376c3595534ebd1f/holidays/countries/pakistan.py#L177-L186
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.
@SaadBazaz See
StaticHolidaysexample i.e. Singapore'shttps://github.com/vacanza/holidays/blob/661581b6eabd4cfa812859a5765b037ef17e8e15/holidays/countries/singapore.py#L257C1-L287C6