-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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,83 @@ | ||
# 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 AUTHORS file) | ||
# dr-prodigy <[email protected]> (c) 2017-2023 | ||
# ryanss <[email protected]> (c) 2014-2017 | ||
# Website: https://github.com/vacanza/python-holidays | ||
# License: MIT (see LICENSE file) | ||
|
||
# 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 SAT, SUN | ||
from holidays.groups import InternationalHolidays, ChristianHolidays | ||
from holidays.holiday_base import HolidayBase | ||
|
||
|
||
class Samoa(HolidayBase, InternationalHolidays, ChristianHolidays): | ||
""" | ||
References: | ||
- https://en.wikipedia.org/wiki/Public_holidays_in_Samoa | ||
- https://www.timeanddate.com/holidays/samoa/ | ||
""" | ||
|
||
country = "WS" | ||
weekend = {SAT, SUN} | ||
|
||
def __init__(self, *args, **kwargs): | ||
ChristianHolidays.__init__(self) | ||
InternationalHolidays.__init__(self) | ||
|
||
super().__init__(*args, **kwargs) | ||
|
||
def _populate(self, year): | ||
super()._populate(year) | ||
|
||
# New Year's Day. | ||
self._add_new_years_day("New Year's Day") | ||
self._add_new_years_day_two("Day After New Year's Day") | ||
|
||
# Good Friday. | ||
self._add_good_friday("Good Friday") | ||
self._add_holy_saturday("Day After Good Friday") | ||
|
||
# Easter Monday. | ||
self._add_easter_monday("Easter Monday") | ||
|
||
# Mother's Day. | ||
self._add_holiday_2nd_mon_of_may("Mother's Day") | ||
|
||
# Independence Day. | ||
self._add_holiday_jun_1("Independence Day") | ||
|
||
# Father's Day. | ||
self._add_holiday_2nd_mon_of_aug("Father's Day") | ||
|
||
# Lotu a Tamaiti (White Monday). | ||
self._add_holiday_2nd_mon_of_oct("Lotu a Tamaiti (White Monday)") | ||
|
||
# Christmas Day. | ||
self._add_christmas_day("Christmas Day") | ||
|
||
# Boxing Day. | ||
self._add_christmas_day_two("Boxing Day") | ||
|
||
|
||
class WS(Samoa): | ||
pass | ||
|
||
|
||
class WSM(Samoa): | ||
pass |
This file contains 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 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 AUTHORS file) | ||
# dr-prodigy <[email protected]> (c) 2017-2023 | ||
# ryanss <[email protected]> (c) 2014-2017 | ||
# Website: https://github.com/vacanza/python-holidays | ||
# License: MIT (see LICENSE file) | ||
|
||
# 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 unittest import TestCase | ||
|
||
from holidays.countries.samoa import Samoa, WS, WSM | ||
from tests.common import CommonCountryTests | ||
|
||
|
||
class TestSamoa(CommonCountryTests, TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass(Samoa, years=range(1950, 2050)) | ||
|
||
def test_country_aliases(self): | ||
self.assertAliases(Samoa, WS, WSM) | ||
|
||
def test_new_years_day(self): | ||
self.assertHolidayName("New Year's Day", (f"{year}-01-01" for year in range(1950, 2050))) | ||
|
||
def test_new_years_second_day(self): | ||
self.assertHolidayName( | ||
"Day After New Year's Day", (f"{year}-01-02" for year in range(1950, 2050)) | ||
) | ||
|
||
def test_independence_day(self): | ||
self.assertHolidayName("Independence Day", (f"{year}-06-01" for year in range(1950, 2050))) | ||
|
||
def test_christmas_day(self): | ||
self.assertHolidayName("Christmas Day", (f"{year}-12-25" for year in range(1950, 2050))) | ||
|
||
def test_boxing_day(self): | ||
self.assertHolidayName("Boxing Day", (f"{year}-12-26" for year in range(1950, 2050))) | ||
|
||
def test_2023(self): | ||
self.assertHolidays( | ||
Samoa(years=2023), | ||
("2023-01-01", "New Year's Day"), | ||
("2023-01-02", "Day After New Year's Day"), | ||
("2023-04-07", "Good Friday"), | ||
("2023-12-26", "Boxing Day"), | ||
("2023-10-09", "Lotu a Tamaiti (White Monday)"), | ||
("2023-05-08", "Mother's Day"), | ||
("2023-06-01", "Independence Day"), | ||
("2023-12-25", "Christmas Day"), | ||
("2023-08-14", "Father's Day"), | ||
("2023-04-10", "Easter Monday"), | ||
("2023-04-08", "Day After Good Friday"), | ||
) | ||
|
||
def test_2024(self): | ||
self.assertHolidays( | ||
Samoa(years=2024), | ||
("2024-01-01", "New Year's Day"), | ||
("2024-01-02", "Day After New Year's Day"), | ||
("2024-12-25", "Christmas Day"), | ||
("2024-04-01", "Easter Monday"), | ||
("2024-12-26", "Boxing Day"), | ||
("2024-05-13", "Mother's Day"), | ||
("2024-03-30", "Day After Good Friday"), | ||
("2024-08-12", "Father's Day"), | ||
("2024-03-29", "Good Friday"), | ||
("2024-06-01", "Independence Day"), | ||
("2024-10-14", "Lotu a Tamaiti (White Monday)"), | ||
) |