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

Update Finland holidays: fix Independence Day appearing pre-1917 #2145

Merged
merged 3 commits into from
Nov 29, 2024
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
6 changes: 4 additions & 2 deletions holidays/countries/finland.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Finland(HolidayBase, ChristianHolidays, InternationalHolidays):
- https://en.wikipedia.org/wiki/Flag_flying_days_in_Finland#Customary_flag_days
- https://intermin.fi/en/flag-and-arms/flag-flying-days
- https://intermin.fi/en/flag-and-arms/flag-days/2024
- https://en.wikipedia.org/wiki/Independence_Day_(Finland)
"""

country = "FI"
Expand Down Expand Up @@ -90,8 +91,9 @@ def _populate_public_holidays(self):
else:
self._add_holiday_nov_1(name)

# Independence Day.
self._add_holiday_dec_6(tr("Itsenäisyyspäivä"))
if self._year >= 1917:
# Independence Day.
self._add_holiday_dec_6(tr("Itsenäisyyspäivä"))

# Christmas Eve.
self._add_christmas_eve(tr("Jouluaatto"))
Expand Down
12 changes: 9 additions & 3 deletions tests/countries/test_finland.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class TestFinland(CommonCountryTests, TestCase):
@classmethod
def setUpClass(cls):
super().setUpClass(Finland)
cls.unofficial_holidays = Finland(categories=UNOFFICIAL, years=range(1853, 2031))
cls.unofficial_holidays = Finland(categories=UNOFFICIAL, years=range(1853, 2050))

def test_country_aliases(self):
self.assertAliases(Finland, FI, FIN)

def test_fixed_holidays(self):
for year in range(2010, 2030):
for year in range(2010, 2050):
self.assertHoliday(
f"{year}-01-01",
f"{year}-01-06",
Expand Down Expand Up @@ -167,12 +167,18 @@ def test_all_saints_day(self):
"1957-11-01",
)

def test_independence_day(self):
name = "Itsenäisyyspäivä"
self.assertHolidayName(name, (f"{year}-12-06" for year in range(1917, 2050)))
self.assertNoHoliday(f"{year}-12-06" for year in range(1853, 1917))
self.assertNoHolidayName(name, range(1853, 1917))

def _test_unofficial_holiday(self, name, since):
start_year, month, day = (int(part) for part in since.split("-"))
self.assertHolidayName(
name,
self.unofficial_holidays,
(f"{year}-{month}-{day}" for year in range(start_year, 2031)),
(f"{year}-{month}-{day}" for year in range(start_year, 2050)),
)
self.assertNoHolidayName(name, self.unofficial_holidays, start_year - 1)

Expand Down