aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Date.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Model/Date.hs')
-rw-r--r--src/Model/Date.hs19
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)