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