+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Giedrius Mauza
Gordon Inggs
Greg Rafferty
Győző Papp
Harshil Gupta
Heikki Orsila
Henrik Sozzi
Hiroki Kawahara
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ and detailed information.

## Available Countries

We currently support 223 country codes. The standard way to refer to a country is by using its [ISO
We currently support 224 country codes. The standard way to refer to a country is by using its [ISO
3166-1 alpha-2 code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes), the same used
for domain names, and for a subdivision its [ISO 3166-2
code](https://en.wikipedia.org/wiki/ISO_3166-2). Some countries have common or foreign names or
Expand Down Expand Up @@ -1274,6 +1274,13 @@ any) in brackets, available languages and additional holiday categories. All cou
<td>WORKDAY</td>
</tr>
<tr>
<td>Pitcairn Islands</td>
<td>PN</td>
<td></td>
<td></td>
<td>GOVERNMENT, WORKDAY</td>
</tr>
<tr>
<td>Poland</td>
<td>PL</td>
<td></td>
Expand Down
1 change: 1 addition & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
from holidays.countries.paraguay import Paraguay, PY, PRY
from holidays.countries.peru import Peru, PE, PER
from holidays.countries.philippines import Philippines, PH, PHL
from holidays.countries.pitcairn_islands import PitcairnIslands, PN, PCN
from holidays.countries.poland import Poland, PL, POL
from holidays.countries.portugal import Portugal, PT, PRT
from holidays.countries.puerto_rico import PuertoRico, PR, PRI, HolidaysPR
Expand Down
85 changes: 85 additions & 0 deletions holidays/countries/pitcairn_islands.py
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"
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
1 change: 1 addition & 0 deletions holidays/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
"paraguay": ("Paraguay", "PY", "PRY"),
"peru": ("Peru", "PE", "PER"),
"philippines": ("Philippines", "PH", "PHL"),
"pitcairn_islands": ("PitcairnIslands", "PN", "PCN"),
"poland": ("Poland", "PL", "POL"),
"portugal": ("Portugal", "PT", "PRT"),
"puerto_rico": ("PuertoRico", "PR", "PRI", "HolidaysPR"),
Expand Down
145 changes: 145 additions & 0 deletions tests/countries/test_pitcairn_islands.py
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
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"),
)
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载