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 ukraine.py #32

Merged
merged 5 commits into from
Dec 24, 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
43 changes: 32 additions & 11 deletions calendra/europe/ukraine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,35 @@ class Ukraine(OrthodoxCalendar):

FIXED_HOLIDAYS = OrthodoxCalendar.FIXED_HOLIDAYS + (
(3, 8, "International Women’s Day"),
(5, 9, "Victory Day"),
)
# Civil holidays
include_labour_day = True
labour_day_label = "Workers Solidarity Day"
# Christian holidays
include_christmas = False
include_orthodox_christmas = False
include_good_friday = True
include_easter_sunday = True
include_easter_monday = True
include_whit_monday = True

def get_fixed_holidays(self, year):
self.include_orthodox_christmas = (year <= 2023)
return super().get_fixed_holidays(year)

def get_variable_days(self, year):
days = super().get_variable_days(year)

# Orthodox Christmas holiday is moved when it falls over the week
orthodox_christmas = date(year, 1, 7)
if orthodox_christmas.weekday() in self.get_weekend_days():
days.append((
self.find_following_working_day(orthodox_christmas),
"Orthodox Christmas (postponed)"))
else:
days.append((orthodox_christmas, "Orthodox Christmas"))
# Last celebrated in 2023
if year <= 2023:
if orthodox_christmas.weekday() in self.get_weekend_days():
days.append((
self.find_following_working_day(orthodox_christmas),
"Orthodox Christmas (postponed)"))
else:
days.append((orthodox_christmas, "Orthodox Christmas"))

# Constitution Day was celebrated for the first time in 1996
if year >= 1996:
Expand All @@ -61,16 +67,31 @@ def get_variable_days(self, year):
days.append((independence_day, "Independence Day"))

# Defender of Ukraine from 2015
# https://en.wikipedia.org/wiki/Defender_of_Ukraine_Day
if year >= 2015:
days.append((date(year, 10, 14), "Day of Defender of Ukraine"))
# https://en.wikipedia.org/wiki/Defenders_Day_(Ukraine)
if year >= 2015 and year <= 2022:
days.append((date(year, 10, 14), "Defenders Day"))
elif year >= 2023:
days.append((date(year, 10, 1), "Defenders Day"))

# Catholic Christmas has become an holiday only starting from 2017
# Catholic Christmas has become a holiday only starting from 2017
if year >= 2017:
days.append((date(year, 12, 25), "Christmas Day"))

# Workers Solidarity Day was celebrated also on the 2nd till 2017
if year <= 2017:
days.append((date(year, 5, 2), "Workers Solidarity Day"))

# WW2 was celebrated on 9th of May but then moved to 8th
if year <= 2023:
days.append((date(year, 5, 9), "Victory Day"))
if year >= 2024:
days.append((date(year, 5, 8), "Day of Remembrance and Victory"))

# Statehood Day celebrated from 2022
# https://en.wikipedia.org/wiki/Statehood_Day_(Ukraine)
if year in (2022, 2023):
days.append((date(year, 7, 28), "Statehood Day"))
if year >= 2024:
days.append((date(year, 7, 15), "Statehood Day"))

return days
34 changes: 30 additions & 4 deletions calendra/tests/test_europe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,7 @@ def test_year_2010(self):
def test_year_2015(self):
holidays = self.cal.holidays_set(2015)
self.assertIn(date(2015, 6, 29), holidays) # Constitution Day (moved)
self.assertIn(date(2015, 10, 14), holidays) # Defender of Ukraine
self.assertIn(date(2015, 10, 14), holidays) # Defenders Day

def test_year_2016(self):
holidays = self.cal.holidays_set(2016)
Expand All @@ -1827,12 +1827,11 @@ def test_year_2016(self):
self.assertIn(date(2016, 3, 8), holidays) # International Women's Day
self.assertIn(date(2016, 5, 1), holidays) # Workers Solidarity Day
self.assertIn(date(2016, 5, 2), holidays) # Workers Solidarity Day
self.assertIn(date(2016, 5, 2), holidays)
self.assertIn(date(2016, 5, 9), holidays) # Victory Day
self.assertIn(date(2016, 6, 20), holidays)
self.assertIn(date(2016, 6, 28), holidays) # Constitution Day
self.assertIn(date(2016, 8, 24), holidays) # Day of Unity
self.assertIn(date(2016, 10, 14), holidays) # Defender of Ukraine
self.assertIn(date(2016, 8, 24), holidays) # Independence Day
self.assertIn(date(2016, 10, 14), holidays) # Defenders Day
self.assertNotIn(date(2016, 12, 25), holidays) # Christmas Day

def test_year_2017(self):
Expand All @@ -1846,6 +1845,33 @@ def test_year_2018(self):
holidays = self.cal.holidays_set(2018)
self.assertNotIn(date(2018, 5, 2), holidays) # Workers Solidarity Day

def test_year_2023(self):
holidays = self.cal.holidays_set(2023)
self.assertIn(date(2023, 1, 1), holidays) # New Year's Day
self.assertIn(date(2023, 1, 7), holidays) # Christmas (Orthodox)
self.assertIn(date(2023, 3, 8), holidays) # International Women's Day
self.assertIn(date(2023, 5, 1), holidays) # Labour Day
self.assertIn(date(2023, 5, 9), holidays) # Victory Day
self.assertIn(date(2023, 6, 28), holidays) # Constitution Day
self.assertIn(date(2023, 7, 28), holidays) # Statehood day
self.assertIn(date(2023, 8, 24), holidays) # Independence Day
self.assertIn(date(2023, 10, 1), holidays) # Defenders Day
self.assertIn(date(2023, 12, 25), holidays) # Christmas Day

def test_year_2024(self):
holidays = self.cal.holidays_set(2024)
self.assertIn(date(2024, 1, 1), holidays) # New Year's Day
self.assertNotIn(date(2024, 1, 7), holidays) # Christmas (Orthodox)
self.assertIn(date(2024, 3, 8), holidays) # International Women's Day
self.assertIn(date(2024, 5, 1), holidays) # Labour Day
self.assertNotIn(date(2024, 5, 9), holidays) # Victory Day
self.assertIn(date(2024, 5, 8), holidays) # Day of Remembrance and Victory
self.assertIn(date(2024, 6, 28), holidays) # Constitution Day
self.assertIn(date(2024, 7, 15), holidays) # Statehood day
self.assertIn(date(2024, 8, 26), holidays) # Independence Day
self.assertIn(date(2024, 10, 1), holidays) # Defenders Day
self.assertIn(date(2024, 12, 25), holidays) # Christmas Day

def test_may_1st_label(self):
holidays = self.cal.holidays(2020)
holidays = dict(holidays)
Expand Down
1 change: 1 addition & 0 deletions newsfragments/32.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated Ukraine holidays.