diff options
author | Joris | 2015-10-10 11:22:03 +0200 |
---|---|---|
committer | Joris | 2015-10-10 11:22:03 +0200 |
commit | 7825b27d262af7252b48e9179a5bbf86b0f30d22 (patch) | |
tree | 2d85883a427fa1183cd5f7737b58e29ba2471828 /src/Mail.hs | |
parent | dd16fd43b09a881a43433174728cf45792cce8ae (diff) |
More readable birthdates in csv file
Diffstat (limited to 'src/Mail.hs')
-rw-r--r-- | src/Mail.hs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Mail.hs b/src/Mail.hs index 7bb6814..dc533ef 100644 --- a/src/Mail.hs +++ b/src/Mail.hs @@ -27,9 +27,9 @@ mailSubject birthdates = mailBody :: Date -> [Birthdate] -> Text mailBody currentDate birthdates = let count = length birthdates - birthdatesWithLines = map (mapFst getLine) . zip [1..] $ birthdates - getLine 1 = if count == 1 then SingleLine else FirstLine - getLine line = if line == count then LastLine else MiddleLine + birthdatesWithLines = map (mapFst lineKind) . zip [1..] $ birthdates + lineKind 1 = if count == 1 then SingleLine else FirstLine + lineKind line = if line == count then LastLine else MiddleLine in T.concat $ map (mailLine currentDate) birthdatesWithLines mapFst :: (a -> c) -> (a, b) -> (c, b) @@ -43,33 +43,33 @@ data Line = deriving (Eq, Show) mailLine :: Date -> (Line, Birthdate) -> Text -mailLine date (SingleLine, birthdate) = +mailLine currDate (SingleLine, birthdate) = T.concat [ fullname birthdate , " is now " - , T.pack . show $ age date birthdate + , T.pack . show $ age currDate birthdate , " years old." ] -mailLine date (FirstLine, birthdate) = +mailLine currDate (FirstLine, birthdate) = T.concat [ fullname birthdate , " is now " - , T.pack . show $ age date birthdate + , T.pack . show $ age currDate birthdate , " years old" ] -mailLine date (MiddleLine, birthdate) = +mailLine currDate (MiddleLine, birthdate) = T.concat [ ", " , fullname birthdate , " is " - , T.pack . show $ age date birthdate + , T.pack . show $ age currDate birthdate , " years old" ] -mailLine date (LastLine, birthdate) = +mailLine currDate (LastLine, birthdate) = T.concat [ " and " , fullname birthdate , " is " - , T.pack . show $ age date birthdate + , T.pack . show $ age currDate birthdate , " years old." ] |