module Date ( Date(..) , getCurrentDate , sameDayAndMonth , yearsGap ) where import Data.Time.Clock import Data.Time.Calendar import Data.Time.LocalTime data Date = Date { day :: Int , month :: Int , year :: Int } deriving (Eq, Show) getCurrentDate :: IO Date getCurrentDate = do now <- getCurrentTime timezone <- getCurrentTimeZone let zoneNow = utcToLocalTime timezone now let (y, m, d) = toGregorian $ localDay zoneNow return $ Date d m (fromIntegral y) sameDayAndMonth :: Date -> Date -> Bool sameDayAndMonth (Date d1 m1 _) (Date d2 m2 _) = m1 == m2 && d1 == d2 yearsGap :: Date -> Date -> Int yearsGap (Date _ _ y1) (Date _ _ y2) = abs (y2 - y1)