bank-holiday-germany 1.0.0.2 → 1.1.0.0
raw patch · 6 files changed
+93/−20 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Time.Calendar.BankHoliday.Germany.ExtraHolidays: InternationalerFrauentag :: ExtraHoliday
Files
- CHANGELOG.md +7/−0
- README.md +3/−1
- bank-holiday-germany.cabal +1/−1
- src/Data/Time/Calendar/BankHoliday/Germany.hs +24/−1
- src/Data/Time/Calendar/BankHoliday/Germany/ExtraHolidays.hs +49/−12
- test/Main.hs +9/−5
CHANGELOG.md view
@@ -22,3 +22,10 @@ - Export `dayToYear` helper function since it is also used by the new module - Add tests - Enhance docs++## [1.1.0.0] - 2024-03-19++### Added++- Add `ExtraHoliday` for Bundesland Berlin+- Add and enhance docs
README.md view
@@ -15,7 +15,9 @@ There are even more public holidays in each federal state which are (partly) covered by the `ExtraHolidays` module of this package. -See the module documentation for more information.+See the [module documentation](https://hackage.haskell.org/package/bank-holiday-germany)+on Hackage for more information.+ -----
bank-holiday-germany.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.6 name: bank-holiday-germany-version: 1.0.0.2+version: 1.1.0.0 synopsis: German bank holidays and public holidays description: Calculation of bank holidays and most public holidays in Germany. homepage: https://github.com/schoettl/bank-holiday-germany#readme
src/Data/Time/Calendar/BankHoliday/Germany.hs view
@@ -8,9 +8,23 @@ holiday is also a legal holiday. Note: There are even more public holidays in each federal state which-are covered by the [@ExtraHolidays@](Data.Time.Calendar.BankHoliday.Germany.ExtraHolidays)+are covered by the [@ExtraHolidays@]("Data.Time.Calendar.BankHoliday.Germany.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: - https://de.wikipedia.org/wiki/Bankfeiertag@@ -106,6 +120,11 @@ -- | 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 --@@ -115,6 +134,10 @@ fromDay day = listToMaybe $ filter (\d -> day == toDay (yearFromDay day) d) [minBound..maxBound] -- | Compute pairs of date and holiday from start to end.+--+-- 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]
src/Data/Time/Calendar/BankHoliday/Germany/ExtraHolidays.hs view
@@ -2,7 +2,7 @@ {-| This module provides additional German public holidays that are not-covered by the [bank holidays](Data.Time.Calendar.BankHoliday.Germany).+covered by the [bank holidays]("Data.Time.Calendar.BankHoliday.Germany"). Public holidays – except for 'Data.Time.Calendar.BankHoliday.Germany.GermanUnityDay' – are under@@ -13,7 +13,7 @@ But there are some additional extra holidays which may differ between federal states. -For example Heilige Drei Könige is not a bank holiday but it is a+For example, Heilige Drei Könige is not a bank holiday but it is a public holiday in Bavaria. Note: The extra holidays are currently only implemented for Bavaria.@@ -22,24 +22,57 @@ Miesbach, Oberbayern) in the next couple years: @- 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 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 - start = fromGregorian 2024 1 1+start = fromGregorian 2024 1 1 - end = fromGregorian 2026 12 31+end = fromGregorian 2025 12 31 - holidays :: [[String]]- holidays = map (\(x,y) -> [show x, BH.germanHolidayName y]) (filter (BH.isPublicHoliday . snd) $ BH.holidaysBetween start end)- ++ map (\(x,y) -> [show x, EH.germanHolidayName y]) (filter ((/=EH.Friedensfest) . snd) $ EH.holidaysBetween EH.Bayern start end)+holidays :: [[String]]+holidays = map (\(x,y) -> [show x, BH.germanHolidayName y]) (filter (BH.isPublicHoliday . snd) $ BH.holidaysBetween start end)+ ++ map (\(x,y) -> [show x, EH.germanHolidayName y]) (filter ((/= EH.Friedensfest) . snd) $ EH.holidaysBetween EH.Bayern start end) - putStrLn $ unlines $ sort $ map unwords holidays+main :: IO ()+main = putStrLn $ unlines $ sort $ map unwords holidays @ +@+2024-01-01 Neujahrstag+2024-01-06 Heilige Drei Könige+2024-03-29 Karfreitag+2024-04-01 Ostermontag+2024-05-01 Tag der Arbeit+2024-05-09 Christi Himmelfahrt+2024-05-20 Pfingstmontag+2024-05-30 Fronleichnam+2024-08-15 Mariä Himmelfahrt+2024-10-03 Tag der Deutschen Einheit+2024-11-01 Allerheiligen+2024-12-25 1. Weihnachtsfeiertag+2024-12-26 2. Weihnachtsfeiertag+2025-01-01 Neujahrstag+2025-01-06 Heilige Drei Könige+2025-04-18 Karfreitag+2025-04-21 Ostermontag+2025-05-01 Tag der Arbeit+2025-05-29 Christi Himmelfahrt+2025-06-09 Pfingstmontag+2025-06-19 Fronleichnam+2025-08-15 Mariä Himmelfahrt+2025-10-03 Tag der Deutschen Einheit+2025-11-01 Allerheiligen+2025-12-25 1. Weihnachtsfeiertag+2025-12-26 2. Weihnachtsfeiertag+@+ Resources: + - Übersicht: https://de.wikipedia.org/wiki/Gesetzliche_Feiertage_in_Deutschland+ - Weitere Übersicht: https://www.arbeitstage.org/ - Bayern: https://www.stmi.bayern.de/suv/feiertage/ -}@@ -90,6 +123,7 @@ | Friedensfest -- ^ Friedensfest (Bayern (Augsburg), …) | MariaeHimmelfahrt -- ^ Mariä Himmelfahrt (Bayern (regional), …) | Allerheiligen -- ^ Allerheiligen (Bayern, …)+ | InternationalerFrauentag -- ^ Internationaler Frauentag (Berlin, …) deriving (Enum, Eq, Bounded, Show, Read) -- | Compute the date for a given year and extra holiday.@@ -102,6 +136,7 @@ toDay year Friedensfest = fromGregorian year 8 8 toDay year MariaeHimmelfahrt = fromGregorian year 8 15 toDay year Allerheiligen = fromGregorian year 11 1+toDay year InternationalerFrauentag = fromGregorian year 3 8 -- | Compute 'Maybe' the holiday for a given date. --@@ -128,6 +163,7 @@ Friedensfest -> "Friedensfest" MariaeHimmelfahrt -> "Mariä Himmelfahrt" Allerheiligen -> "Allerheiligen"+ InternationalerFrauentag -> "Internationaler Frauentag" -- | Check if 'ExtraHoliday' is a holiday in the given federal state. --@@ -142,4 +178,5 @@ isHolidayInState Bayern Friedensfest = True isHolidayInState Bayern MariaeHimmelfahrt = True isHolidayInState Bayern Allerheiligen = True+isHolidayInState Berlin InternationalerFrauentag = True isHolidayInState _ _ = False
test/Main.hs view
@@ -2,6 +2,7 @@ module Main (main) where import Data.Time.Calendar.BankHoliday.Germany+import Data.Time.Calendar.BankHoliday.Germany.ExtraHolidays (ExtraHoliday(..), FederalState(..)) import Data.Time.Calendar.BankHoliday.Germany.ExtraHolidays qualified as EH import Data.Time.Calendar.WeekDate import Data.Time@@ -71,17 +72,20 @@ describe "Data.Time.Calendar.BankHoliday.Germany.ExtraHolidays" $ do describe "FederalState" $ it "has right number of states" $- length [minBound .. maxBound :: EH.FederalState] `shouldBe` 16+ length [minBound .. maxBound :: FederalState] `shouldBe` 16 describe "toDay" $ it "works for Fronleichnam (depending on Easter Sunday)" $ do -- https://www.arbeitstage.org/feiertage/fronleichnam/- map (\y -> show $ EH.toDay y EH.Fronleichnam) [2024..2027]+ map (\y -> show $ EH.toDay y Fronleichnam) [2024..2027] `shouldBe` ["2024-05-30", "2025-06-19", "2026-06-04", "2027-05-27"] describe "holidaysBetween" $ do it "only has Bavaria's extra holidays" $- map snd (EH.holidaysBetween EH.Bayern (day 2024 11 1) (day 2024 12 31))- `shouldBe` [EH.Allerheiligen]+ map snd (EH.holidaysBetween Bayern (day 2024 11 1) (day 2024 12 31))+ `shouldBe` [Allerheiligen]+ it "there is only one extra holiday in Berlin" $ do+ filter (EH.isHolidayInState Berlin) [minBound..maxBound]+ `shouldBe` [InternationalerFrauentag] it "has no holidays for other states yet => otherwise, please add tests" $ do- let statesExceptBavaria = filter (/=EH.Bayern) [minBound..maxBound]+ let statesExceptBavaria = filter (not . flip elem [Bayern, Berlin]) [minBound..maxBound] let holidays = concatMap (\x -> EH.holidaysBetween x (day 2024 1 1) (day 2024 12 31)) statesExceptBavaria holidays `shouldBe` []