diff options
author | Joris | 2015-11-29 14:43:06 +0100 |
---|---|---|
committer | Joris | 2015-11-29 14:43:06 +0100 |
commit | e6269b6750d50c2f72bf534e32c020f0554705a7 (patch) | |
tree | 5247f2f6a8f207a8ee022b02614ba01b7488849c /src/Model/Birthdate.hs | |
parent | b0f00782ebc9ca6825a6c87b41e5c4888c009a65 (diff) |
Use next week range to compute next week age and next week day of birthdates
Diffstat (limited to 'src/Model/Birthdate.hs')
-rw-r--r-- | src/Model/Birthdate.hs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/Model/Birthdate.hs b/src/Model/Birthdate.hs index f871860..96783a7 100644 --- a/src/Model/Birthdate.hs +++ b/src/Model/Birthdate.hs @@ -5,13 +5,13 @@ module Model.Birthdate , renderBirthdate , fullname , age - , ageNextWeek , filterBirthdayAt - , filterBirthdayBetween + , filterBirthdayInside ) where import Data.Text (Text) import qualified Data.Text as T +import Data.Maybe (isJust) import Model.Date @@ -36,18 +36,8 @@ fullname d = T.concat [firstname d, " ", lastname d] age :: Date -> Birthdate -> Int age currentDate birthdate = yearsGap currentDate (date birthdate) -ageNextWeek :: Date -> Birthdate -> Int -ageNextWeek currentDate birthdate = - (+1) $ (daysGap currentDate (date birthdate)) `div` 365 - 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 ( begin `isBeforeOrEqualDayAndMonth` d - && d `isBeforeOrEqualDayAndMonth` end - ) - ) +filterBirthdayInside :: [Date] -> [Birthdate] -> [Birthdate] +filterBirthdayInside dates = filter (isJust . dayAndMonthInRange dates . date) |