aboutsummaryrefslogtreecommitdiff
path: root/src/Date.hs
diff options
context:
space:
mode:
authorJoris2015-10-10 11:34:06 +0200
committerJoris2015-10-10 11:34:06 +0200
commit93efd341228034e26240101f7df185ed5b65831c (patch)
tree82ea0365f3afad2aaa81900589c6d81233fe045c /src/Date.hs
parent3ba512849f7b0ed184f2c06b481a7838ecdbe1e2 (diff)
downloadevents-93efd341228034e26240101f7df185ed5b65831c.tar.gz
events-93efd341228034e26240101f7df185ed5b65831c.tar.bz2
events-93efd341228034e26240101f7df185ed5b65831c.zip
Modeling dates as day - month - year
Diffstat (limited to 'src/Date.hs')
-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)