diff options
author | Joris | 2015-11-22 01:56:20 +0100 |
---|---|---|
committer | Joris | 2015-11-22 01:56:20 +0100 |
commit | b977bb5ba3d5ad8f8008aa4ceb60d1f988a82a0a (patch) | |
tree | b27b15ea4ea6e7f983259d9c9708ac200e562251 /src/Model/Date.hs | |
parent | 5375ad26dd78220185f1ffe05222250c06dc1a0c (diff) |
Generate a mail that contains both birthdays today and birthdays next week
Diffstat (limited to 'src/Model/Date.hs')
-rw-r--r-- | src/Model/Date.hs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/Model/Date.hs b/src/Model/Date.hs index 96c15e9..e095cc6 100644 --- a/src/Model/Date.hs +++ b/src/Model/Date.hs @@ -7,8 +7,8 @@ module Model.Date , plusDays , sameDayAndMonth , isBeforeOrEqualDayAndMonth - , isAfterOrEqualDayAndMonth , yearsGap + , daysGap ) where import Data.Time.Clock @@ -40,8 +40,10 @@ getNextWeek = do return (begin, end) plusDays :: Date -> Int -> Date -plusDays (Date d m y) n = - dateFromDay . addDays (toInteger n) $ fromGregorian (toInteger y) m d +plusDays date n = dateFromDay . addDays (toInteger n) . dateToDay $ date + +dateToDay :: Date -> Day +dateToDay (Date d m y) = fromGregorian (toInteger y) m d dateFromDay :: Day -> Date dateFromDay dayTime = @@ -62,13 +64,8 @@ isBeforeOrEqualDayAndMonth d1 d2 = ) ) -isAfterOrEqualDayAndMonth :: Date -> Date -> Bool -isAfterOrEqualDayAndMonth d1 d2 = - ( month d1 > month d2 - || ( month d1 == month d2 - && day d1 >= day d2 - ) - ) - yearsGap :: Date -> Date -> Int yearsGap d1 d2 = abs (year d2 - year d1) + +daysGap :: Date -> Date -> Int +daysGap d1 d2 = abs . fromIntegral $ (dateToDay d1) `diffDays` (dateToDay d2) |