Skip to content
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

Add Vanuatu holidays #1423

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Available Countries
.. _ISO 639-1 code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
.. _ISO 639-2 code: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

We currently support 131 country codes. The standard way to refer to a country
We currently support 132 country codes. The standard way to refer to a country
is by using its `ISO 3166-1 alpha-2 code`_, the same used for domain names, and
for a subdivision its `ISO 3166-2 code`_. Some of the countries support more
than one language for holiday names output.
Expand Down Expand Up @@ -637,6 +637,10 @@ The list of supported countries, their subdivisions and supported languages
- UZ
-
-
* - Vanuatu
- VU
-
-
* - Vatican City
- VA
-
Expand Down
1 change: 1 addition & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
from .united_states_virgin_islands import UnitedStatesVirginIslands, VI, VIR, HolidaysVI
from .uruguay import Uruguay, UY, URY
from .uzbekistan import Uzbekistan, UZ, UZB
from .vanuatu import Vanuatu, VU, VTU
from .vatican_city import VaticanCity, VA, VAT
from .venezuela import Venezuela, VE, VEN
from .vietnam import Vietnam, VN, VNM
Expand Down
87 changes: 87 additions & 0 deletions holidays/countries/vanuatu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# python-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: dr-prodigy <[email protected]> (c) 2017-2023
# ryanss <[email protected]> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars.gregorian import FEB, MAR, JUL, OCT, NOV
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays


class Vanuatu(HolidayBase, ChristianHolidays, InternationalHolidays):
"""
https://en.wikipedia.org/wiki/Public_holidays_in_Vanuatu
https://www.timeanddate.com/holidays/vanuatu/
https://www.gov.vu/index.php/events/holidays
"""

country = "VU"

def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
super().__init__(*args, **kwargs)

def _populate(self, year):
# On 30 July 1980, Vanuatu gained independence from Britain and France.
if year <= 1980:
return None

super()._populate(year)

# New Years Day.
self._add_new_years_day("New Year's Day")

if year >= 1991:
# Father Lini Day
self._add_holiday("Father Lini Day", FEB, 21)

# Custom Chief's Day
self._add_holiday("Custom Chief's Day", MAR, 5)

# Good Friday
self._add_good_friday("Good Friday")

# Easter Monday
self._add_easter_monday("Easter Monday")

# Labour Day
self._add_labor_day("Labour Day")

# Ascension Day
self._add_ascension_thursday("Ascension Day")

# Children's Day
self._add_holiday("Children's Day", JUL, 24)

# Independence Day
self._add_holiday("Independence Day", JUL, 30)

# Assumption Day
self._add_assumption_of_mary_day("Assumption Day")

# Constitution Day
self._add_holiday("Constitution Day", OCT, 5)

# National Unity Day
self._add_holiday("National Unity Day", NOV, 29)

# Christmas Day
self._add_christmas_day("Christmas Day")

# Family day
self._add_christmas_day_two("Family Day")


class VU(Vanuatu):
pass


class VTU(Vanuatu):
pass
1 change: 1 addition & 0 deletions holidays/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"united_states": ("UnitedStates", "US", "USA"),
"uruguay": ("Uruguay", "UY", "URY"),
"uzbekistan": ("Uzbekistan", "UZ", "UZB"),
"vanuatu": ("Vanuatu", "VU", "VTU"),
"vatican_city": ("VaticanCity", "VA", "VAT"),
"venezuela": ("Venezuela", "VE", "VEN"),
"vietnam": ("Vietnam", "VN", "VNM"),
Expand Down
49 changes: 49 additions & 0 deletions tests/countries/test_vanuatu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# python-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: dr-prodigy <[email protected]> (c) 2017-2023
# ryanss <[email protected]> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.countries.vanuatu import Vanuatu, VU, VTU
from tests.common import TestCase


class TestVanuatu(TestCase):
@classmethod
def setUpClass(cls):
super().setUpClass(Vanuatu)

def test_country_aliases(self):
self.assertCountryAliases(Vanuatu, VU, VTU)

def test_no_holidays(self):
self.assertNoHolidays(Vanuatu(years=1980))

def test_fater_lini_day(self):
arkid15r marked this conversation as resolved.
Show resolved Hide resolved
name = "Father Lini Day"
self.assertHolidayName(name, (f"{year}-02-21" for year in range(1991, 2050)))
self.assertNoHolidayName(name, Vanuatu(years=range(1981, 1991)))
self.assertNoHoliday(f"{year}-02-21" for year in range(1981, 1991))

def test_2022(self):
self.assertHolidays(
("2022-01-01", "New Year's Day"),
("2022-02-21", "Father Lini Day"),
("2022-03-05", "Custom Chief's Day"),
("2022-04-15", "Good Friday"),
("2022-04-18", "Easter Monday"),
("2022-05-01", "Labour Day"),
("2022-05-26", "Ascension Day"),
("2022-07-24", "Children's Day"),
("2022-07-30", "Independence Day"),
("2022-08-15", "Assumption Day"),
("2022-10-05", "Constitution Day"),
("2022-11-29", "National Unity Day"),
("2022-12-25", "Christmas Day"),
("2022-12-26", "Family Day"),
)