Skip to content

Commit

Permalink
Merge pull request #341 from steinfurt/berlin-holidays
Browse files Browse the repository at this point in the history
Add Berlin specific holidays. Fixes #340
  • Loading branch information
brunobord committed Mar 15, 2019
2 parents 0c004e0 + de1614d commit 3b0f712
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Added isolated tests for shifting mechanics in USA calendars - previously untested (#335).
- Added Barbados by @ludsoft.
- Added Berlin specific holidays (#340).

## v4.2.0 (2019-02-21)

Expand Down
16 changes: 16 additions & 0 deletions workalendar/europe/germany.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ class Bavaria(Germany):
class Berlin(Germany):
'Berlin'

def get_international_womens_day(self, year):
day = date(year, 3, 8)
return (day, "International Women's Day")

def get_liberation_day(self, year):
day = date(year, 5, 8)
return (day, "Liberation Day")

def get_variable_days(self, year):
days = super(Berlin, self).get_variable_days(year)
if year >= 2019:
days.append(self.get_international_womens_day(year))
if year == 2020:
days.append(self.get_liberation_day(year))
return days


@iso_register('DE-BB')
class Brandenburg(Germany):
Expand Down
20 changes: 20 additions & 0 deletions workalendar/tests/test_germany.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ def test_year_2015(self):
class BerlinTest(GermanyTest):
cal_class = Berlin

def test_extra_2018(self):
holidays = self.cal.holidays_set(2018)
self.assertNotIn(date(2018, 3, 8), holidays)
self.assertNotIn(date(2018, 5, 8), holidays)

def test_extra_2019(self):
holidays = self.cal.holidays_set(2019)
self.assertIn(date(2019, 3, 8), holidays)
self.assertNotIn(date(2019, 5, 8), holidays)

def test_extra_2020(self):
holidays = self.cal.holidays_set(2020)
self.assertIn(date(2020, 3, 8), holidays)
self.assertIn(date(2020, 5, 8), holidays)

def test_extra_2021(self):
holidays = self.cal.holidays_set(2021)
self.assertIn(date(2021, 3, 8), holidays)
self.assertNotIn(date(2021, 5, 8), holidays)


class BrandenburgTest(GenericCalendarTest):
cal_class = Brandenburg
Expand Down

0 comments on commit 3b0f712

Please sign in to comment.