Skip to content

Commit

Permalink
Update Finland holidays: fix Independence Day appearing pre-1917 (#2145)
Browse files Browse the repository at this point in the history
Co-authored-by: ~Jhellico <[email protected]>
  • Loading branch information
PPsyrius and KJhellico authored Nov 29, 2024
1 parent 3d2e28a commit 7cc644a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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

0 comments on commit 7cc644a

Please sign in to comment.