Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
This module computes general bank holidays.
Most of these bank holidays are also public aka legal holidays
throughout Germany. You can use isPublicHoliday
to check if a
holiday is also a legal holiday.
Note: There are even more public holidays in each federal state which
are covered by the ExtraHolidays
module of this package.
You can test this package or just calculate a few bank holidays with GHCi:
$ stack ghci --package time --package bank-holiday-germany ghci> import Data.Time ghci> import Data.Time.Calendar.BankHoliday.Germany ghci> isBankHoliday (fromGregorian 2024 5 1) -- Tag der Arbeit True ghci> isPublicHoliday ChristmasEve False ghci> holidaysBetween (fromGregorian 2024 12 1) (fromGregorian 2024 12 26) [(2024-12-24,ChristmasEve),(2024-12-25,ChristmasDay),(2024-12-26,SecondChristmasDay)]
Resources:
Synopsis
- data BankHoliday
- isBankHoliday :: Day -> Bool
- isPublicHoliday :: BankHoliday -> Bool
- calculateEasterSunday :: Year -> Day
- holidaysBetween :: Day -> Day -> [(Day, BankHoliday)]
- fromDay :: Day -> Maybe BankHoliday
- toDay :: Year -> BankHoliday -> Day
- germanHolidayName :: BankHoliday -> String
- yearFromDay :: Day -> Year
Documentation
data BankHoliday Source #
Data type specifying German bank holidays including Christmas Eve and New Year's Eve.
Note: This type cannot be an instance of class Ord
because due to
Easter day calculation the order can change from year to year.
NewYearsDay | Neujahrstag |
GoodFriday | Karfreitag |
EasterMonday | Ostermontag |
LabourDay | Tag der Arbeit |
AscensionDay | Christi Himmelfahrt |
WhitMonday | Pfingstmontag |
GermanUnityDay | Tag der Deutschen Einheit |
ChristmasEve | Heilig Abend |
ChristmasDay | 1. Weihnachtsfeiertag |
SecondChristmasDay | 2. Weihnachtsfeiertag |
NewYearsEve | Silvestertag |
Instances
isBankHoliday :: Day -> Bool Source #
Check if a given day is a BankHoliday
.
>>>
isBankHoliday (fromGregorian 2024 1 1)
True
isPublicHoliday :: BankHoliday -> Bool Source #
True only for German public holidays aka legal holidays. Chrismas Eve and New Year's Eve are bank holidays but not public holidays.
calculateEasterSunday :: Year -> Day Source #
Calculate Easter Sunday using Spencer's algorithm.
holidaysBetween :: Day -> Day -> [(Day, BankHoliday)] Source #
Compute pairs of date and holiday from start to end (inclusive).
Note: In some years, two bank holidays can fall on the same
day. In such cases only one of them is in the resulting list.
See fromDay
for more information.
>>>
map snd $ holidaysBetween (fromGregorian 2024 12 25) (fromGregorian 2024 12 26)
[ChristmasDay,SecondChristmasDay]
fromDay :: Day -> Maybe BankHoliday Source #
Compute Maybe
the holiday for a given date.
Note: In some years, two bank holidays can fall on the same
day. E.g. LabourDay
and AscensionDay
in 2008 are both on
2008-05-01. In such cases this function returns the bank holiday
that is defined first in the BankHoliday
Enum
.
>>>
fromDay (fromGregorian 2024 1 1)
Just NewYearsDay
>>>
fromDay (fromGregorian 2024 5 5)
Nothing
toDay :: Year -> BankHoliday -> Day Source #
Compute the date for a given year and bank holiday.
>>>
toDay 2024 LabourDay
2024-05-01
germanHolidayName :: BankHoliday -> String Source #
Translate the holiday name to German.
yearFromDay :: Day -> Year Source #
Helper to extract the year from a date.
>>>
yearFromDay $ fromGregorian 2020 1 1
2020