aboutsummaryrefslogtreecommitdiff
path: root/src/Birthdate.hs
diff options
context:
space:
mode:
authorJoris2015-11-21 17:32:28 +0100
committerJoris2015-11-21 17:32:28 +0100
commit6850159bf998a209ad7b6d7103d113a54659937e (patch)
treeb2aadbf5fc516927a7c527f995fb829cffc551d4 /src/Birthdate.hs
parent94da91e1db4a5c130aa50579473e6a0a6b7a7958 (diff)
downloadevents-6850159bf998a209ad7b6d7103d113a54659937e.tar.gz
events-6850159bf998a209ad7b6d7103d113a54659937e.tar.bz2
events-6850159bf998a209ad7b6d7103d113a54659937e.zip
Add filter birthday between function
Diffstat (limited to 'src/Birthdate.hs')
-rw-r--r--src/Birthdate.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/Birthdate.hs b/src/Birthdate.hs
index c9d0bda..48d3a4e 100644
--- a/src/Birthdate.hs
+++ b/src/Birthdate.hs
@@ -4,13 +4,13 @@ module Birthdate
( Birthdate(..)
, fullname
, age
- , filterBirthday
+ , filterBirthdayAt
) where
import Data.Text (Text)
import qualified Data.Text as T
-import Date (Date, sameDayAndMonth, yearsGap)
+import Date
data Birthdate = Birthdate
{ date :: Date
@@ -24,5 +24,14 @@ fullname d = T.concat [firstname d, " ", lastname d]
age :: Date -> Birthdate -> Int
age currentDate birthdate = yearsGap currentDate (date birthdate)
-filterBirthday :: Date -> [Birthdate] -> [Birthdate]
-filterBirthday d = filter (sameDayAndMonth d . date)
+filterBirthdayAt :: Date -> [Birthdate] -> [Birthdate]
+filterBirthdayAt d = filter (sameDayAndMonth d . date)
+
+filterBirthdayBetween :: Date -> Date -> [Birthdate] -> [Birthdate]
+filterBirthdayBetween begin end =
+ filter (\bd ->
+ let d = date bd
+ in ( d `isAfterOrEqualDayAndMonth` begin
+ && d `isBeforeOrEqualDayAndMonth` end
+ )
+ )