aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2015-10-10 11:34:06 +0200
committerJoris2015-10-10 11:34:06 +0200
commit93efd341228034e26240101f7df185ed5b65831c (patch)
tree82ea0365f3afad2aaa81900589c6d81233fe045c
parent3ba512849f7b0ed184f2c06b481a7838ecdbe1e2 (diff)
Modeling dates as day - month - year
-rw-r--r--src/Date.hs10
1 files changed, 5 insertions, 5 deletions
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)