packages feed

holidays 0.3.0.1 → 0.3.0.2

raw patch · 7 files changed

+113/−4 lines, 7 filesdep +hebrew-timePVP ok

version bump matches the API change (PVP)

Dependencies added: hebrew-time

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -13,3 +13,9 @@  ## **0.3.0.0** - 2025-08-20 - default language is Haskell2010++## **0.3.0.1** - 2026-05-05+- make OverloadedStrings a default extension++## **0.3.0.2** - 2026-05-07+- new country supported: ISR
holidays.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: holidays-version: 0.3.0.1+version: 0.3.0.2 synopsis: Library for country public holidays description:   Public holidays with Haskell.@@ -25,6 +25,7 @@   build-depends:     base ^>=4.19.0.0,     containers ^>=0.7,+    hebrew-time ^>=0.1.2,     text ^>=2.1,     time >=1.4 && <2, @@ -41,6 +42,7 @@     Holidays.DateFinder     Holidays.DateTransform     Holidays.Germany+    Holidays.Israel     Holidays.Mozambique     Holidays.Namibia     Holidays.SouthAfrica@@ -64,6 +66,7 @@   other-modules:     Test.Holidays     Test.Holidays.Germany+    Test.Holidays.Israel     Test.Holidays.Mozambique     Test.Holidays.Namibia     Test.Holidays.SouthAfrica
src/Holidays.hs view
@@ -15,6 +15,7 @@ import Holidays.Base import Holidays.DateTransform import qualified Holidays.Germany as DEU+import qualified Holidays.Israel as ISR import qualified Holidays.Mozambique as MOZ import qualified Holidays.Namibia as NAM import qualified Holidays.SouthAfrica as ZAF@@ -38,6 +39,7 @@   case countryCode of     "DEU" -> DEU.holidays regions `apply` year     "GBR" -> GBR.holidays `apply` year+    "ISR" -> S.union (ISR.holidays `apply` year) (ISR.sabbaths year)     "MOZ" -> MOZ.holidays `apply` year     "NAM" -> NAM.holidays `apply` year     "USA" -> USA.holidays `apply` year
src/Holidays/DateFinder.hs view
@@ -118,7 +118,7 @@ before :: Day -> Integer -> Maybe DayOfWeek -> Day before = timeTravel Past --- | Time-travel to the past in number of days. Includes the specified Day.+-- | Time-travel to the future in number of days. Includes the specified Day. after :: Day -> Integer -> Maybe DayOfWeek -> Day after = timeTravel Future 
+ src/Holidays/Israel.hs view
@@ -0,0 +1,56 @@+{--+  references:+  https://en.wikipedia.org/wiki/Public_holidays_in_Israel+--}+module Holidays.Israel (+  holidays,+  sabbaths,+) where++import qualified Data.Set as S++-- import Data.Text (show)+import qualified Data.Text as T+import Data.Time+import qualified Data.Time.Calendar.Hebrew as H++import Holidays.Base++-- import Holidays.DateFinder+import Holidays.DateTransform++holidays :: ([Year -> Holiday], [DateTransform])+holidays =+  ( [ hday "new_year_1" . jewishHoliday H.Tishrei 1,+      hday "new_year_2" . jewishHoliday H.Tishrei 2,+      hday "day_of_atonement" . jewishHoliday H.Tishrei 10,+      hday "feast_of_tabernacles" . jewishHoliday H.Tishrei 15,+      hday "simchat_torah" . jewishHoliday H.Tishrei 22,+      hday "passover" . jewishHoliday H.Nissan 15,+      hday "seventh_day_of_passover" . jewishHoliday H.Nissan 21,+      hday "independence_day" . jewishHoliday H.Iyar 5,+      hday "shavout" . jewishHoliday H.Sivan 6,+      hday "tisha_bav" . jewishHoliday H.Av 9+    ],+    []+  )++-- | Convert jewish holiday to from hebrew date to gregorian date.+jewishHoliday :: H.Month -> Int -> Year -> Day+jewishHoliday m d y =+  case ds' of+    [] -> nullDay+    (d' : _) -> d'+  where+    ds = map (\hy -> H.fromHebrew (H.HebrewDate (H.year hy) m d)) (hebrewDates y)+    ds' = filter (\d' -> let (y', _, _) = toGregorian d' in y' == y) ds -- filter with specified year++{- |+Gets hebrew dates based on Jan 1 of gregorian year.+Use year and offset by +1 and -1 to deal with year edge discrepencies when converting to hebrew dates.+-}+hebrewDates :: Year -> [H.HebrewDate]+hebrewDates y = map (\x -> H.toHebrew (fromGregorian (y + x) January 1)) [-1, 0, 1]++sabbaths :: Year -> S.Set Holiday+sabbaths = S.fromList . map (\(i, d) -> hday ("sabbath_" <> (T.show i)) d) . zip [1 :: Int ..] . filter (\d -> dayOfWeek d == Saturday) . periodAllDays
tst/Main.hs view
@@ -1,6 +1,7 @@ module Main where  import qualified Test.Holidays.Germany as DEU+import qualified Test.Holidays.Israel as ISR import qualified Test.Holidays.Mozambique as MOZ import qualified Test.Holidays.Namibia as NAM import qualified Test.Holidays.SouthAfrica as ZAF@@ -15,7 +16,7 @@ tests = testGroup "Holidays tests" [unitTests, propTests]  unitTests :: TestTree-unitTests = testGroup "Unit tests" [DEU.unitTests, GBR.unitTests, MOZ.unitTests, NAM.unitTests, USA.unitTests, ZAF.unitTests]+unitTests = testGroup "Unit tests" [DEU.unitTests, GBR.unitTests, ISR.unitTests, MOZ.unitTests, NAM.unitTests, USA.unitTests, ZAF.unitTests]  propTests :: TestTree-propTests = testGroup "Holidays property based tests" [DEU.propTests, GBR.propTests, MOZ.propTests, NAM.propTests, USA.propTests, ZAF.propTests]+propTests = testGroup "Holidays property based tests" [DEU.propTests, GBR.propTests, ISR.propTests, MOZ.propTests, NAM.propTests, USA.propTests, ZAF.propTests]
+ tst/Test/Holidays/Israel.hs view
@@ -0,0 +1,41 @@+{--+ - references:+ - https://www.timeanddate.com/holidays/israel/2024+--}+module Test.Holidays.Israel (+  unitTests,+  propTests,+) where++import Data.List+import qualified Data.Set as S+import qualified Data.Text as T+import Holidays+import Test.Holidays+import Test.Tasty+import Test.Tasty.HUnit++unitTests :: TestTree+unitTests =+  testGroup+    "ISR unit tests"+    [ testCase "2024" $+        sortOn holidayValue (excludeSabbaths (S.toAscList (holidays "ISR" [] 2024)))+          @?= [ hday "passover" (day 2024 4 23),+                hday "seventh_day_of_passover" (day 2024 4 29),+                hday "independence_day" (day 2024 5 13),+                hday "shavout" (day 2024 6 12),+                hday "tisha_bav" (day 2024 8 13),+                hday "new_year_1" (day 2024 10 3),+                hday "new_year_2" (day 2024 10 4),+                hday "day_of_atonement" (day 2024 10 12),+                hday "feast_of_tabernacles" (day 2024 10 17),+                hday "simchat_torah" (day 2024 10 24)+              ]+    ]++propTests :: TestTree+propTests = countryPropTests "ISR" []++excludeSabbaths :: [Holiday] -> [Holiday]+excludeSabbaths hs = filter (not . T.isPrefixOf "sabbath_" . holidayKey) hs