Skip to content

Commit 97e5bc2

Browse files
authored
Merge pull request #245 from hf-kklein/subdivisions
2 parents 47b7dac + 878f078 commit 97e5bc2

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ classifiers = [
5050
"Programming Language :: Python :: 3.13",
5151
]
5252
dependencies = [
53-
"holidays>=0.59;python_version>='3.9'",
53+
"holidays>=0.78;python_version>='3.9'",
5454
"pytz>=2022.7.1",
5555
"python-dateutil",
5656
]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# pip-compile pyproject.toml
66
#
7-
holidays==0.77 ; python_version >= "3.9"
7+
holidays==0.78 ; python_version >= "3.9"
88
# via bdew_datetimes (pyproject.toml)
99
python-dateutil==2.9.0.post0
1010
# via

src/bdew_datetimes/calendar.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,29 @@ def _populate(self, year: int) -> None:
3535
)
3636

3737

38+
_relevant_subdivisions: list[str] = [
39+
"BB", # Brandenburg.
40+
"BE", # Berlin.
41+
"BW", # Baden-Württemberg.
42+
"BY", # Bayern.
43+
"HB", # Bremen.
44+
"HE", # Hessen.
45+
"HH", # Hamburg.
46+
"MV", # Mecklenburg-Vorpommern.
47+
"NI", # Niedersachsen.
48+
"NW", # Nordrhein-Westfalen.
49+
"RP", # Rheinland-Pfalz.
50+
"SH", # Schleswig-Holstein.
51+
"SL", # Saarland.
52+
"SN", # Sachsen.
53+
"ST", # Sachsen-Anhalt.
54+
"TH", # Thüringen.
55+
# This list contains an explicit list of all BDEW calendar relevant Germany subdivisions.
56+
# It does _not_ include the 'Augsburg' subdivision which has been added in holidays v0.78.
57+
# https://github.com/vacanza/holidays/commit/feab68b4377369ad52eeee9e98fc8316ec0c6f86
58+
]
59+
60+
3861
def create_bdew_calendar() -> HolidaySum:
3962
"""Creates a calendar containing all days considered by the BDEW.
4063
@@ -64,7 +87,7 @@ def create_bdew_calendar() -> HolidaySum:
6487
# If a day is holiday in any subdivision, the holiday is valid nationwide.
6588
# Therefore, we add all subdivisions of Germany to the BDEW specific holidays.
6689
# Currently, in Germany holidays are not observed.
67-
for subdivision in Germany.subdivisions:
90+
for subdivision in _relevant_subdivisions:
6891
# the method __add__ expects a Union[int, "HolidayBase", "HolidaySum"] as `other`
6992
# here, we're dealing with a child instance of HolidayBase
7093
result += Germany(

tests/test_calendar.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ def test_bdew_holidays(expected_holiday: date) -> None:
3131
pytest.param(date(2024, 11, 20), True, id="Buß- und Bettag (SN)"),
3232
pytest.param(date(2024, 12, 31), True, id="Silvester 2024 (BDEW)"),
3333
pytest.param(date(2025, 6, 6), True, id="Sonderfeiertag 2025 (BDEW)"),
34+
pytest.param(
35+
date(2025, 8, 8),
36+
False,
37+
id="Augsburger Friedensfest is not BDEW relevant",
38+
),
3439
],
3540
)
3641
def test_create_bdew_calendar(

0 commit comments

Comments
 (0)