-
-
Notifications
You must be signed in to change notification settings - Fork 558
Add Pitcairn Islands holidays #2704
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e01e543
Adding changes in tests and pitcairn_islands.py
Harshil-Gupta 21a96c0
Implementing Code Review Suggestions
PPsyrius 3479e72
Merge branch 'dev' into dev
PPsyrius eaa166c
Increments country count
PPsyrius 510acbf
Cleanup code comments
PPsyrius aea0d89
Fix wrong date for ANZAC Day test
PPsyrius 4135c88
Update docstring and tests
KJhellico 8321a01
Update CONTRIBUTORS
arkid15r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# 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) | ||
|
||
from holidays.constants import GOVERNMENT, PUBLIC, WORKDAY | ||
from holidays.groups import ChristianHolidays, InternationalHolidays | ||
from holidays.holiday_base import HolidayBase | ||
|
||
|
||
class PitcairnIslands(HolidayBase, ChristianHolidays, InternationalHolidays): | ||
"""Pitcairn Islands holidays. | ||
|
||
References: | ||
* <https://en.wikipedia.org/wiki/Public_holidays_in_Pitcairn_Islands> | ||
* [Public Holidays & Commemoration Days (2016)](https://web.archive.org/web/20161112174923/https://www.government.pn/policies/GPI%20-%20Approved%20Public%20Holidays%20&%20Commemoration%20Days.pdf) | ||
* [Public Holidays & Commemoration Days (2024)](https://web.archive.org/web/20250517050245/https://static1.squarespace.com/static/6526ff6fef608a3828c13d05/t/6673d53b1c0e2f660cc31848/1718867262145/GPI_Policy_Public_Holidays_&_Commemoration_Days_June_2024.pdf) | ||
* [The Laws of Pitcairn, Henderson, Ducie and Oeno Islands - Volume I](https://web.archive.org/web/20240418043000/https://static1.squarespace.com/static/6526ff6fef608a3828c13d05/t/65585fca2ce3972fb3bc8da3/1700290563094/Revised+Laws+of+Pitcairn,+Henderson,+Ducie+and+Oeno+Islands,+2017+Rev.+Ed.+-+Volume+1.pdf) | ||
* [CIA The World Factbook](https://web.archive.org/web/20211217233431/https://www.cia.gov/the-world-factbook/countries/pitcairn-islands/) | ||
""" | ||
|
||
country = "PN" | ||
KJhellico marked this conversation as resolved.
Show resolved
Hide resolved
PPsyrius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
supported_categories = (GOVERNMENT, PUBLIC, WORKDAY) | ||
# First available online source. | ||
start_year = 2016 | ||
|
||
def __init__(self, *args, **kwargs): | ||
ChristianHolidays.__init__(self) | ||
InternationalHolidays.__init__(self) | ||
super().__init__(*args, **kwargs) | ||
|
||
def _populate_public_holidays(self): | ||
# New Year's Day. | ||
self._add_new_years_day("New Year's Day") | ||
|
||
# Bounty Day. | ||
self._add_holiday_jan_23("Bounty Day") | ||
|
||
# Good Friday. | ||
self._add_good_friday("Good Friday") | ||
|
||
# Easter Monday. | ||
self._add_easter_monday("Easter Monday") | ||
|
||
if self._year >= 2023: | ||
# King's Birthday. | ||
self._add_holiday_1st_mon_of_jun("King's Birthday") | ||
else: | ||
# Queen's Birthday. | ||
self._add_holiday_2nd_sat_of_jun("Queen's Birthday") | ||
|
||
# Pitcairn Day. | ||
self._add_holiday_jul_2("Pitcairn Day") | ||
|
||
# Christmas Day. | ||
self._add_christmas_day("Christmas Day") | ||
|
||
# Boxing Day. | ||
self._add_christmas_day_two("Boxing Day") | ||
|
||
def _populate_government_holidays(self): | ||
# New Year's Day. | ||
self._add_new_years_day_two("New Year's Day") | ||
|
||
def _populate_workday_holidays(self): | ||
# ANZAC Day. | ||
self._add_anzac_day("ANZAC Day") | ||
|
||
# Remembrance Day. | ||
self._add_remembrance_day("Remembrance Day") | ||
|
||
|
||
class PN(PitcairnIslands): | ||
pass | ||
|
||
|
||
class PCN(PitcairnIslands): | ||
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# 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) | ||
|
||
from unittest import TestCase | ||
|
||
from holidays.constants import GOVERNMENT, WORKDAY | ||
from holidays.countries.pitcairn_islands import PitcairnIslands, PN, PCN | ||
PPsyrius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from tests.common import CommonCountryTests | ||
|
||
|
||
class TestPitcairnIslands(CommonCountryTests, TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
years = range(2016, 2050) | ||
super().setUpClass(PitcairnIslands, years=years) | ||
cls.government_holidays = PitcairnIslands(categories=GOVERNMENT, years=years) | ||
cls.workday_holidays = PitcairnIslands(categories=WORKDAY, years=years) | ||
|
||
def test_country_aliases(self): | ||
self.assertAliases(PitcairnIslands, PN, PCN) | ||
|
||
def test_no_holidays(self): | ||
self.assertNoHolidays( | ||
PitcairnIslands(categories=PitcairnIslands.supported_categories, years=2015) | ||
) | ||
|
||
def test_new_years_day(self): | ||
name = "New Year's Day" | ||
# Public Holidays. | ||
self.assertHolidayName(name, (f"{year}-01-01" for year in range(2016, 2050))) | ||
# Government Holidays. | ||
self.assertHolidayName( | ||
name, self.government_holidays, (f"{year}-01-02" for year in range(2016, 2050)) | ||
) | ||
self.assertNoHolidayName(name, (f"{year}-01-02" for year in range(2016, 2050))) | ||
|
||
def test_bounty_day(self): | ||
self.assertHolidayName("Bounty Day", (f"{year}-01-23" for year in range(2016, 2050))) | ||
|
||
def test_good_friday(self): | ||
name = "Good Friday" | ||
self.assertHolidayName( | ||
name, | ||
"2021-04-02", | ||
"2022-04-15", | ||
"2023-04-07", | ||
"2024-03-29", | ||
"2025-04-18", | ||
) | ||
self.assertHolidayName(name, range(2016, 2050)) | ||
|
||
def test_easter_monday(self): | ||
name = "Easter Monday" | ||
self.assertHolidayName( | ||
name, | ||
"2021-04-05", | ||
"2022-04-18", | ||
"2023-04-10", | ||
"2024-04-01", | ||
"2025-04-21", | ||
) | ||
self.assertHolidayName(name, range(2016, 2050)) | ||
|
||
def test_queens_birthday(self): | ||
name = "Queen's Birthday" | ||
self.assertHolidayName( | ||
name, | ||
"2016-06-11", | ||
"2017-06-10", | ||
"2018-06-09", | ||
"2019-06-08", | ||
"2020-06-13", | ||
"2021-06-12", | ||
"2022-06-11", | ||
) | ||
self.assertNoHolidayName(name, range(2023, 2050)) | ||
|
||
def test_kings_birthday(self): | ||
name = "King's Birthday" | ||
self.assertHolidayName( | ||
name, | ||
"2023-06-05", | ||
"2024-06-03", | ||
"2025-06-02", | ||
) | ||
self.assertHolidayName(name, range(2023, 2050)) | ||
self.assertNoHolidayName(name, range(2016, 2023)) | ||
|
||
def test_pitcairn_day(self): | ||
self.assertHolidayName("Pitcairn Day", (f"{year}-07-02" for year in range(2016, 2050))) | ||
|
||
def test_christmas_day(self): | ||
self.assertHolidayName("Christmas Day", (f"{year}-12-25" for year in range(2016, 2050))) | ||
|
||
def test_boxing_day(self): | ||
self.assertHolidayName("Boxing Day", (f"{year}-12-26" for year in range(2016, 2050))) | ||
|
||
def test_anzac_day(self): | ||
name = "ANZAC Day" | ||
self.assertNoHolidayName(name) | ||
self.assertHolidayName( | ||
name, self.workday_holidays, (f"{year}-04-25" for year in range(2016, 2050)) | ||
) | ||
|
||
def test_remembrance_day(self): | ||
name = "Remembrance Day" | ||
self.assertNoHolidayName(name) | ||
self.assertHolidayName( | ||
name, self.workday_holidays, (f"{year}-11-11" for year in range(2016, 2050)) | ||
) | ||
|
||
def test_2022_public(self): | ||
self.assertHolidays( | ||
PitcairnIslands(years=2022), | ||
("2022-01-01", "New Year's Day"), | ||
("2022-01-23", "Bounty Day"), | ||
("2022-04-15", "Good Friday"), | ||
("2022-04-18", "Easter Monday"), | ||
("2022-06-11", "Queen's Birthday"), | ||
("2022-07-02", "Pitcairn Day"), | ||
("2022-12-25", "Christmas Day"), | ||
("2022-12-26", "Boxing Day"), | ||
) | ||
|
||
def test_2022_government(self): | ||
self.assertHolidays( | ||
PitcairnIslands(categories=GOVERNMENT, years=2022), | ||
("2022-01-02", "New Year's Day"), | ||
) | ||
|
||
def test_2022_workday(self): | ||
self.assertHolidays( | ||
PitcairnIslands(categories=WORKDAY, years=2022), | ||
("2022-04-25", "ANZAC Day"), | ||
("2022-11-11", "Remembrance Day"), | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.