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 d1 d2 = ( day d1 == day d2 && month d1 == month d2 ) yearsGap :: Date -> Date -> Int yearsGap d1 d2 = abs (year d2 - year d1)