bank-holiday-germany: German bank holidays and public holidays

[ library, mit, time ] [ Propose Tags ] [ Report a vulnerability ]

Calculation of bank holidays and public holidays in Germany.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0.0, 1.0.0.1, 1.0.0.2, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.3.1.0, 2.0.0.0, 2.0.1.0, 2.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), time (>=1.12.2 && <1.15) [details]
License MIT
Copyright 2024 Jakob Schöttl
Author Jakob Schöttl
Maintainer jakob.schoettl@intensovet.de
Category Time
Home page https://github.com/schoettl/bank-holiday-germany#readme
Source repo head: git clone https://github.com/schoettl/bank-holiday-germany
Uploaded by schoettl at 2025-04-18T05:26:16Z
Distributions LTSHaskell:1.3.1.0, NixOS:1.3.0.0, Stackage:2.1.0.0
Downloads 324 total (21 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for bank-holiday-germany-2.1.0.0

[back to package description]

bank-holiday-germany

See below for a German version.

This package provides calculation of bank holidays and public holidays in Germany.

Most bank holidays are also public aka legal holidays throughout Germany. You can use isPublicHoliday to check if a holiday is also a public holiday.

There are even more public holidays in each federal state.

Public holidays are generally off for all employees. Bank holidays that are not public holidays are generally only off for bank employees.

See the module documentation on Hackage for more information.


Dieses Modul behandelt deutsche Bankfeiertage und gesetzliche Feiertage.

Bis auf Heilig Abend und Silvester sind alle Bankfeiertage gleichzeitig gesetzliche Feiertage in allen Bundesländern der Bundesrepublik Deutschland. Die Funktion isPublicHoliday prüft ob ein Bankfeiertag auch ein gesetzlicher Feiertag ist.

Darüber hinaus gibt es je nach Bundesland weitere gesetzliche Feiertage.

Für alle 16 Bundesländer sind damit die jeweiligen Feiertage vollständig implementiert (Stand 2024-03-31).

Bankfeiertage sind in der Regel für Bankangestellte frei. Gesetzliche Feiertage sind in der Regel für alle Angestellten frei (im Bundesland für das sie gelten).

Vorsicht: Manche gesetzliche Feiertage gelten nicht für ein ganzes Bundesland sondern nur für bestimmte Landkreise, z.B. das Friedensfest in Augsburg.

Gesetzliche Feiertage sind übrigens Ländersache – abgesehen vom Nationalfeiertag Tag der Deutschen Einheit.

A rewrite to version 2

Sorry for the incompatible changes introduced by the rewrite to version 2. The rational for the big refactoring was to simplify the library's interface by unifying BankHoliday and ExtraHoliday types.

How to migrate to version 2

The following functions haven't changed semantically:

toDay :: Year -> Holiday -> Day
fromDay :: Day -> [Holiday]
holidaysBetween :: Day -> Day -> [(Day, Holiday)]
germanHolidayName :: Holiday -> String

However, they are now returning more holidays – not only bank holidays but the union of all kind of holidays of all federal states.

It's now on you to filter for the holidays you're interested in. You can use the following functions:

isBankHoliday :: Holiday -> Bool
isGermanPublicHoliday :: Holiday -> Bool
isFederalPublicHoliday :: FederalState -> Holiday -> Bool

Changes:

  • isPublicHoliday has been renamed to isGermanPublicHoliday.
  • isBankHoliday now takes a Holiday instead of a Day.
  • The namespace changed from Data.Time.Calendar.BankHoliday.Germany to Data.Holiday.Germany.
  • fromDay now returns a list of holidays instead of a Maybe.

Why didn't you get the design right in the first place?

For version 1, I looked on hackage for other holiday packages and there have been two conventions:

  1. bank-holiday-* with modules like Data.Time.Calendar.BankHoliday.*
  2. *-holidays with modules like Data.Holiday.*

I settled with the first scheme because I initially only wanted to provide bank holidays and had no plans to support all federal holidays. The library evolved and over time we added support for public holidays and federal holidays. That was when the library's interface got complicated.

The module path was long, clumsy and inaccurate because it wasn't only about bank holidays anymore.

Why the mix of english function names and german type constructors?

I choose to use german names for type constructors for simplicity and consistency. It's hard enough to find a common name and notation for German holidays (e.g. "1. Mai", "1. Maifeiertag", "Tag der Arbeit", etc.). But it's getting harder to find translations for e.g. "Augsburger Friedensfest" ("Augsburg High Festival of Peace" – source: bavarikon.de – doesn't sound right).

Also, many German users of this library will have an easier time when they don't have to look up words like "Whit Monday", "Ascension Day", or "Epiphany".

Sample code for version 2

Rank federal states by number of holidays:

test2.hs:

import Prelude
import Data.List
import Data.Time
import Data.Holiday.Germany

holidays :: Year -> FederalState -> [(Day, Holiday)]
holidays year state = filter (isFederalPublicHoliday state . snd) $ holidaysBetween start end
  where
    start = fromGregorian year 1 1
    end = fromGregorian year 12 31

supportedFederalStates :: [FederalState]
supportedFederalStates = [minBound .. maxBound]

year :: Year
year = 2025

showPadded :: Int -> String
showPadded n | n < 10 = " " ++ show n
             | otherwise = show n

main :: IO ()
main = putStrLn
         $ unlines
         $ map (\(x, n) -> showPadded n ++ "  " ++ show x)
         $ sortOn ((0-) . snd)
         $ map (\x -> (x, length $ holidays year x))
         $ supportedFederalStates
$ stack runghc --package time test2.hs
14  Bayern
12  BadenWuerttemberg
12  Saarland
12  Thueringen
11  MecklenburgVorpommern
11  NordrheinWestfalen
11  RheinlandPfalz
11  Sachsen
11  SachsenAnhalt
10  Berlin
10  Brandenburg
10  Bremen
10  Hamburg
10  Hessen
10  Niedersachsen
10  SchleswigHolstein

More examples:

Sample code for version 1

Rank federal states by number of holidays:

test1.hs:

import Prelude
import Data.List
import Data.Time
import qualified Data.Time.Calendar.BankHoliday.Germany as BH
import qualified Data.Time.Calendar.BankHoliday.Germany.ExtraHolidays as EH
import Data.Time.Calendar.BankHoliday.Germany (BankHoliday(..))
import Data.Time.Calendar.BankHoliday.Germany.ExtraHolidays (FederalState(..), ExtraHoliday(..))

holidays :: Year -> FederalState -> [Day]
holidays year state = map fst (filter (BH.isPublicHoliday . snd) $ BH.holidaysBetween start end)
                   ++ map fst (EH.holidaysBetween state start end)
  where
    start = fromGregorian year 1 1
    end = fromGregorian year 12 31


supportedFederalStates :: [FederalState]
supportedFederalStates = [minBound .. maxBound]

year :: Year
year = 2024

showPadded :: Int -> String
showPadded n | n < 10 = " " ++ show n
             | otherwise = show n

main :: IO ()
main = putStrLn
         $ unlines
         $ map (\(x, n) -> showPadded n ++ "  " ++ show x)
         $ sortOn ((0-) . snd)
         $ map (\x -> (x, length $ holidays year x))
         $ supportedFederalStates
$ stack script --resolver=lts-22.0 --package time --package bank-holiday-germany test1.hs
14  Bayern
12  BadenWuerttemberg
12  Saarland
12  Thueringen
11  MecklenburgVorpommern
11  NordrheinWestfalen
11  RheinlandPfalz
11  Sachsen
11  SachsenAnhalt
10  Berlin
10  Brandenburg
10  Bremen
10  Hamburg
10  Hessen
10  Niedersachsen
10  SchleswigHolstein

More examples: