blob: 4c6e3982f15b49bd5c9d0becb1a4305bb05cd66f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
{-# LANGUAGE OverloadedStrings #-}
module Birthdate
( Birthdate(..)
, fullname
, age
, filterBirthday
) where
import Data.Text (Text)
import qualified Data.Text as T
import Date (Date, sameDayAndMonth, yearsGap)
data Birthdate = Birthdate
{ date :: Date
, lastname :: Text
, firstname :: Text
} deriving (Eq, Show)
fullname :: Birthdate -> Text
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)
|