From 93efd341228034e26240101f7df185ed5b65831c Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 10 Oct 2015 11:34:06 +0200 Subject: Modeling dates as day - month - year --- src/Date.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Date.hs') diff --git a/src/Date.hs b/src/Date.hs index 07f0672..6660f24 100644 --- a/src/Date.hs +++ b/src/Date.hs @@ -10,9 +10,9 @@ import Data.Time.Calendar import Data.Time.LocalTime data Date = Date - { year :: Int + { day :: Int , month :: Int - , day :: Int + , year :: Int } deriving (Eq, Show) getCurrentDate :: IO Date @@ -21,10 +21,10 @@ getCurrentDate = do timezone <- getCurrentTimeZone let zoneNow = utcToLocalTime timezone now let (y, m, d) = toGregorian $ localDay zoneNow - return $ Date (fromIntegral y) m d + return $ Date d m (fromIntegral y) sameDayAndMonth :: Date -> Date -> Bool -sameDayAndMonth (Date _ m1 d1) (Date _ m2 d2) = m1 == m2 && d1 == d2 +sameDayAndMonth (Date d1 m1 _) (Date d2 m2 _) = m1 == m2 && d1 == d2 yearsGap :: Date -> Date -> Int -yearsGap (Date y1 _ _) (Date y2 _ _) = abs (y2 - y1) +yearsGap (Date _ _ y1) (Date _ _ y2) = abs (y2 - y1) -- cgit v1.2.3